Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
983 changes: 983 additions & 0 deletions Anchal_Hora/panel/.vs/config/applicationhost.config

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions Anchal_Hora/panel/Database/SQLQuery14.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE TABLE EmpInformation(SNo int primary key, Projectid VARCHAR(200) , name VARCHAR(500) ,email VARCHAR(200) UNIQUE , [PASSWORD] VARCHAR(200) , [ROLE] VARCHAR(500), ContactNo bigint, ProjectName VARCHAR(200) );

INSERT INTO EmpInformation VALUES ('1', 'P1', 'Anchal','horaanchal@gmail.com', 'anchal', 'User1', '6656676878', 'Web development');
INSERT INTO EmpInformation VALUES ('2', 'P1', 'Anjali','horaanjali@gmail.com', 'anjali', 'User2', '7867665676', 'Web development');
INSERT INTO EmpInformation VALUES ('3', 'P2', 'Ankush','horaankush@gmail.com', 'ankush', 'User3', '6656566766', 'AI');
INSERT INTO EmpInformation VALUES ('4', 'P2', 'Resham','horaresham@gmail.com', 'resham', 'User4', '8990876774','AI');
INSERT INTO EmpInformation VALUES ('5', 'P1', 'Ansh','horaansh@gmail.com', 'ansh', 'Reporting Manager1', '7545347667', 'Web development');
INSERT INTO EmpInformation VALUES ('6', 'P2', 'Aditya','horaaditya@gmail.com', 'aditya', 'Reporting Manager2', '6378656789', 'AI');
INSERT INTO EmpInformation VALUES ('7','', 'Raghav','horaraghavl@gmail.com', 'raghav', 'Admin', '5653424789','');

SELECT * from EmpInformation ;
70 changes: 70 additions & 0 deletions Anchal_Hora/panel/Login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
function func(){
console.log("Hello Bhai lpg");
window.location.href = "./admin/index.html";
console.log("Hello Bhai b ehen");
}
//document.getElementById("button").addEventListener("click",Gettoken)
function Gettoken(){

var Sno=parseInt(document.getElementById("inputid").value);
var Username=document.getElementById("inputName").value;
var Email=document.getElementById("inputEmail").value;
var Password=document.getElementById("inputPassword").value;


var get = {
"Sno":Sno,
"Name":Username,
"Email":Email,
"Password":Password
};
console.log(get);
//sendHTTPReq('POST', "http://localhost:51391/api/Panel", json).then(x => func() );
var xhr= new XMLHttpRequest();
var url="http://localhost:51391/api/Login";
xhr.open('POST', url,true);
xhr.responseType='json';
xhr.setRequestHeader('Content-type','application/json');
console.log(JSON.stringify(get));
xhr.onload = () => {
console.log(xhr.status);
//var jwtToken = xhr.response.token;

};
xhr.send(JSON.stringify(get));
}

// //console.log("Plain Object -- "+ get);
// apiRequest(get)

// }
// function apiRequest(get){
// let getObject = get;
// //console.log("object in apirequest getObject);
// const xhr= new XMLHttpRequest();
Comment thread
horaanchal marked this conversation as resolved.
Outdated
// const url="http://localhost:51391/api/Login";
// xhr.open('POST', url);
// xhr.responseType='json';
// xhr.setRequestHeader('Content-type','application/json');
// //console.log(JSON.stringify(getObject));
// debugger;
// xhr.onload = () => {
// console.log(xhr.status);
// //var jwtToken = xhr.response.token;

// };
// xhr.send(JSON.stringify(json));
// }
// // let jToken = {};
// // jToken = xhr.response.token;
// // //console.log(xhr.response.token);
// // console.log(xhr.status);
// // //console.log(xhr.response);
// // console.log(jToken);
// // // var jwtToken = xhr.response.token;

// // };
// // //console.log("object in apiRequest"+JSON.stringify(get));
// // debugger;
// // xhr.send(JSON.stringify(get));
// // }
25 changes: 25 additions & 0 deletions Anchal_Hora/panel/WebApplicationPanel.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.1000
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplicationPanel", "WebApplicationPanel\WebApplicationPanel.csproj", "{EC1659EB-707D-416C-8BD0-AD72DD2CCE40}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EC1659EB-707D-416C-8BD0-AD72DD2CCE40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC1659EB-707D-416C-8BD0-AD72DD2CCE40}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC1659EB-707D-416C-8BD0-AD72DD2CCE40}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC1659EB-707D-416C-8BD0-AD72DD2CCE40}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6291CE64-2D3B-4B27-BB96-989FDEF68E3B}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.IdentityModel.Tokens;
using WebApplicationPanel.DbModels;

// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace WebappAPItype.Controllers
{
[Route("api/[controller]")]
[ApiController]

public class LoginController : Controller
{
private panelContext _panelcontext;
private IConfiguration _config;
private panelContext _panelContext;

public LoginController(IConfiguration config, panelContext panelcontext)

{
_panelcontext = panelcontext;
_config = config;
}

[HttpPost]
public IActionResult Login([FromBody] WebApplicationPanel.DbModels.EmpInformation login)
Comment thread
horaanchal marked this conversation as resolved.
Outdated
{
IActionResult response = Unauthorized();
var user = AuthenticateUser(login);

if (user != null)
{
var tokenString = GenerateJSONWebToken(user);
response = Ok(new { token = tokenString });
}

return response;
}

//private object AuthenticateUser(EmpInformation login)
//{
// throw new NotImplementedException();
//}

private object GenerateJSONWebToken(object user)
{
throw new NotImplementedException();
}

//private object AuthenticateUser(DbModels.UserInformation login)
//{
// throw new NotImplementedException();
//}

private string GenerateJSONWebToken(EmpInformation userInfo)
{
var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Jwt:Key"]));
var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);
var claims = new[] {
new Claim("Name", userInfo.Name),
new Claim("Email", userInfo.Email),
new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())
};


var token = new JwtSecurityToken(_config["Jwt:Issuer"],
_config["Jwt:Issuer"],
claims,
expires: DateTime.Now.AddMinutes(120),
signingCredentials: credentials);

return new JwtSecurityTokenHandler().WriteToken(token);
}

private WebApplicationPanel.DbModels.EmpInformation AuthenticateUser(WebApplicationPanel.DbModels.EmpInformation login)
{
EmpInformation user = _panelcontext.EmpInformation.Where(u => u.Sno == login.Sno && u.Password == login.Password).FirstOrDefault();
if (user != null)
{
user = new WebApplicationPanel.DbModels.EmpInformation { Email = user.Email, Name=user.Name };
}
return user;
}
}
}
10 changes: 10 additions & 0 deletions Anchal_Hora/panel/WebApplicationPanel/Controllers/Panel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace WebApplicationPanel.Controllers
{
internal class Panel
{
public int Sno { get; internal set; }
public int Username { get; internal set; }
public string Emailid { get; internal set; }
public string Password { get; internal set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using System.Configuration;
using Microsoft.AspNetCore.Mvc;
using WebApplicationPanel.DbModels;
using WebappAPItype.CustomModels;
using Microsoft.Extensions.Configuration;

namespace WebApplicationPanel.Controllers
{
[Route("api/[controller]")]
[ApiController]

Comment thread
horaanchal marked this conversation as resolved.

public class PanelController : ControllerBase
{
panelContext _panelContext;

//private object panelContext;
//private object panel;

public PanelController(panelContext panelContext)
{
_panelContext = panelContext;
}

// [HttpGet]
//public IActionResult heyAanchal()
//{
Comment thread
horaanchal marked this conversation as resolved.
Outdated
// return Ok("Yipeee-Ke-Yay");
//}


[HttpPost]
public IActionResult Createpanel([FromBody]PanelRequest panelRequest)
{
EmpInformation panel = new EmpInformation();
panel.Sno = panelRequest.Sno;
panel.Name = panelRequest.Name;
panel.Email = panelRequest.Email;
panel.Password = panelRequest.Password;

_panelContext.EmpInformation.Add(panel);
_panelContext.SaveChanges();
return Ok("Employee Added");

}

[HttpPut("{id}")]

public ActionResult Put(int id, [FromBody]PanelRequest panelRequest)
{
EmpInformation panel = _panelContext.EmpInformation.Find(id);
panel.Email = panelRequest.Email;
panel.Name = panelRequest.Name;
panel.Password = panelRequest.Password;
// _panelContext.EmpInformation.Update(panel);
_panelContext.SaveChanges();
return Ok("Employee updated");

}

[HttpDelete("{id}")]

public ActionResult<string> Delete(int id)
{
EmpInformation output = _panelContext.EmpInformation.Where(x => x.Sno == id).FirstOrDefault();
if (output == null)
{
return NotFound();
}
//EmpInformation e = new EmpInformation { Sno = id };

_panelContext.EmpInformation.Remove(output);
_panelContext.SaveChanges();
return Ok("Employee Deleted");
}
}
}

20 changes: 20 additions & 0 deletions Anchal_Hora/panel/WebApplicationPanel/CustomModels/PanelRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace WebappAPItype.CustomModels
{
public class PanelRequest
{
public int Sno { get; set; }
public string Projectid { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public string Role { get; set; }
public long? ContactNo { get; set; }
public string ProjectName { get; set; }

}
}
17 changes: 17 additions & 0 deletions Anchal_Hora/panel/WebApplicationPanel/DbModels/EmpInformation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;

namespace WebApplicationPanel.DbModels
{
public partial class EmpInformation
{
public int Sno { get; set; }
public string Projectid { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public string Role { get; set; }
public long? ContactNo { get; set; }
public string ProjectName { get; set; }
}
}
Loading