public ActionResult Create(tblEmployeeDetail employeeDetail, HttpPostedFileBase FileUpload) { using (BusManagementContext db = new BusManagementContext()) { try { //Save image in folder string FileName = Path.GetFileName(FileUpload.FileName); string SaveLocation = Server.MapPath("~/EmployeePicture/" + FileName); FileUpload.SaveAs(SaveLocation); //save image name in database employeeDetail.employeeImage = "~/EmployeePicture/" + FileName; // byte image Save employeeDetail.employeePicture = new byte[FileUpload.ContentLength]; ViewBag.TeacherPicture = FileUpload.InputStream.Read(employeeDetail.employeePicture, 0, FileUpload.ContentLength); db.tblEmployeeDetails.Add(employeeDetail); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } } }
public void UpdateEmployeeDetails(Employee employee) { tblEmployeeDetail objTblEmployeeDetail = new tblEmployeeDetail(); objTblEmployeeDetail = entities.tblEmployeeDetails.ToList().Find(objTblEmployee => objTblEmployee.EmployeeDetailsID == employee.EmployeeID); UpdateEmployee(objTblEmployeeDetail, employee); }
public bool AddNewEmployee(Employee objEmployee, bool IsPermanent) { tblEmployeeDetail objTblEmployeeDetail = new tblEmployeeDetail(); try { objTblEmployeeDetail.FirstName = objEmployee.FirstName; objTblEmployeeDetail.LastName = objEmployee.LastName; objTblEmployeeDetail.Email = objEmployee.Email; objTblEmployeeDetail.Mobile = objEmployee.Mobile; objTblEmployeeDetail.Phone = objEmployee.Phone; // tblAddress bb = bb.tblEmployeeDetails..FirstOrDefault(); objTblEmployeeDetail.tblAddress = ConvertAddress(objEmployee.CommunicationAddress); if (!IsPermanent) { objTblEmployeeDetail.tblAddress1 = ConvertAddress(objEmployee.PermanentAddress); } else { //objTblEmployeeDetail.tblAddress1 = ConvertAddress(objEmployee.CommunicationAddress); objTblEmployeeDetail.ISPermanentCommunicationSame = true; } entities.tblEmployeeDetails.Add(objTblEmployeeDetail); entities.SaveChanges(); } catch (Exception e) { IsSuccess = false; } return(IsSuccess); }
public Employee FetchEmployeeDetails(int EmployeeID) { tblEmployeeDetail objTblEmployeeDetail = new tblEmployeeDetail(); objTblEmployeeDetail = entities.tblEmployeeDetails.ToList().Find(objTblEmployee => objTblEmployee.EmployeeDetailsID == EmployeeID); return(objEmployee = ConvertTblEmployee(objTblEmployeeDetail)); }
public tblEmployeeDetail AddempDetail(int empid, Nullable <DateTime> joiningdate, decimal salary) { var adddetail = new tblEmployeeDetail() { EmployeeId = empid, EmployeeStatus = "Active", Dateofjoining = joiningdate, IsSalaryset = true, EmployeeSalary = salary, }; return(adddetail); }
// GET: Employees/Create public ActionResult Create() { using (BusManagementContext db = new BusManagementContext()) { tblEmployeeDetail t = new tblEmployeeDetail(); ViewBag.DepartmentDropdown = db.tblDepartments.ToList(); ViewBag.DesignationsDropdown = db.tblDesignations.ToList(); ViewBag.GenderDropdown = db.tblGenders.ToList(); return(View(t)); } }
// GET: Employees/Details/5 public ActionResult Details(int?id) { using (BusManagementContext db = new BusManagementContext()) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblEmployeeDetail emp = db.tblEmployeeDetails.Find(id); if (emp == null) { return(HttpNotFound()); } return(View(emp)); } }
public ActionResult Delete(int id) { using (BusManagementContext db = new BusManagementContext()) { try { tblEmployeeDetail emp = db.tblEmployeeDetails.Find(id); db.tblEmployeeDetails.Remove(emp); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } } }
public ActionResult EmployeeMaster(EmployeeMasters objMaster) { tblEmployeeDetail master = new tblEmployeeDetail(); master.EmpName = objMaster.EmpName; master.EmpCode = objMaster.EmpCode; master.EmpDesignationID = objMaster.EmpDesignationID; master.EmpDept = objMaster.EmpDept; master.PhoneNo = objMaster.PhoneNo; master.CreatedDate = Convert.ToDateTime(System.DateTime.Now.ToString("dd-MM-yyyy hh:mm")); master.ModifiedDate = Convert.ToDateTime(System.DateTime.Now.ToString("dd-MM-yyyy hh:mm")); master.IsActive = true; objAdminEnti.tblEmployeeDetails.Add(master); objAdminEnti.SaveChanges(); TempData["Success"] = "Employee added successfully."; return(RedirectToAction("EmployeeMaster")); // return View(); }
public void UpdateEmployee(tblEmployeeDetail objTblEmp, Employee objEmployee) { objTblEmp.FirstName = objEmployee.FirstName; objTblEmp.LastName = objEmployee.LastName; objTblEmp.Email = objEmployee.Email; objTblEmp.Mobile = objEmployee.Mobile; objTblEmp.Phone = objEmployee.Phone; tblAddress objAddress = ConvertAddress(objEmployee.CommunicationAddress); tblAddress objTblAddress = entities.tblAddresses.Find(objAddress.AddressID); objTblAddress.Address1 = objAddress.Address1; objTblAddress.Address2 = objAddress.Address2; objTblAddress.Address3 = objAddress.Address3; objTblAddress.StateID = objAddress.StateID; objTblAddress.DistrictID = objAddress.DistrictID; objTblAddress.CityID = objAddress.CityID; objTblAddress.Pincode = objAddress.Pincode; objTblEmp.CommunicationAddressID = objAddress.AddressID; tblAddress objAddress1 = ConvertAddress(objEmployee.PermanentAddress); tblAddress objTblAddress1 = entities.tblAddresses.Find(objAddress1.AddressID); objTblAddress1.Address1 = objAddress1.Address1; objTblAddress1.Address2 = objAddress1.Address2; objTblAddress1.Address3 = objAddress1.Address3; objTblAddress1.StateID = objAddress1.StateID; objTblAddress1.DistrictID = objAddress1.DistrictID; objTblAddress1.CityID = objAddress1.CityID; objTblAddress1.Pincode = objAddress1.Pincode; objTblEmp.PermanentAddressID = objTblAddress1.AddressID; //objTblEmp.tblAddress1 = ConvertAddress(objEmployee.PermanentAddress); entities.SaveChanges(); }
// GET: Employees/Edit/5 public ActionResult Edit(int?id) { using (BusManagementContext db = new BusManagementContext()) { ViewBag.DepartmentDropdown = db.tblDepartments.ToList(); ViewBag.DesignationsDropdown = db.tblDesignations.ToList(); ViewBag.GenderDropdown = db.tblGenders.ToList(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblEmployeeDetail emp = db.tblEmployeeDetails.Find(id); if (emp == null) { return(HttpNotFound()); } return(View(emp)); } }
public Employee ConvertTblEmployee(tblEmployeeDetail objTblEmployee) { objEmployee.EmployeeID = objTblEmployee.EmployeeDetailsID; objEmployee.FirstName = objTblEmployee.FirstName; objEmployee.LastName = objTblEmployee.LastName; objEmployee.Email = objTblEmployee.Email; objEmployee.Mobile = objTblEmployee.Mobile; objEmployee.Phone = objTblEmployee.Phone; objEmployee.CommunicationAddress = ConvertTblAddress(objTblEmployee.tblAddress); if (!objTblEmployee.ISPermanentCommunicationSame) { objEmployee.PermanentAddress = ConvertTblAddress(objTblEmployee.tblAddress1); } else { objEmployee.PermanentAddress = ConvertTblAddress(objTblEmployee.tblAddress); } return(objEmployee); }
public void Addempdetail(tblEmployeeDetail obj) { context.tblEmployeeDetails.Add(obj); }
public ActionResult Edit(tblEmployeeDetail objEmployeeDetail) { return(View()); }
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { //context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" }); var emailId = AESEncrytDecry.DecryptStringAES(context.UserName); var password = AESEncrytDecry.DecryptStringAES(context.Password); tblEmployeeDetail userData = null; tblEmployeeJobDetail jobDeatils = null; var data = context.OwinContext.Get <ICONHRContext>(); try { userData = data.EmployeeDetails.FirstOrDefault(x => x.EmailID == emailId); jobDeatils = data.EmployeeJobDetails.FirstOrDefault(x => x.EmpID == userData.EmpID); } catch (Exception e) { Console.WriteLine(e); throw; } if (userData == null) { context.SetError("invalid_grant", "The user name or password is incorrect."); return; } // bool isMatchPassword = PasswordHash.ValidatePassword(password, "1000:" + Convert.ToString(userData.PasswordSalt) + ":" + Convert.ToString(userData.PasswordHash)); if (userData.PasswordSalt != context.Password) { context.SetError("invalid_grant", "The user name or password is incorrect."); // return; } // string imgData = Base64EncodeBytes(userData.ProfilePhoto); string profilePhoto = string.Empty; if (userData.ProfilePhoto != null) { profilePhoto = Convert.ToBase64String(userData.ProfilePhoto); } var companyDetail = data.CompanyDetails.Where(x => x.CompanyID == userData.CompanyID).FirstOrDefault(); if (userData.CreatedDate.HasValue && userData.CreatedDate.Value.AddDays(30) < DateTime.Now) { if (companyDetail.IsTrailEnd && !companyDetail.IsPaid) { //throw new Exception("Payment Redirection"); context.SetError("PaymentRedirection", "Payment Redirection"); return; } } else { if (companyDetail.IsTrailEnd && !companyDetail.IsPaid) { context.SetError("PaymentRedirection", "Payment Redirection"); return; } } var claims = new List <Claim>(); claims.Add(new Claim(ClaimTypes.Name, userData.EmpName)); claims.Add(new Claim(ClaimTypes.Email, userData.EmailID)); claims.Add(new Claim("UserId", userData.EmpID.ToString())); claims.Add(new Claim("CompanyId", userData.CompanyID.ToString())); if (companyDetail.CompanyName != null) { // claims.Add(new Claim("CompanyName", companyDetail.CompanyName)); } claims.Add(new Claim(ClaimTypes.SerialNumber, userData.EmpID.ToString())); //claims.Add(new Claim("ProfilePhoto", userData.ProfilePhoto)); // claims.Add(userData.ProfilePhoto); claims.Add(new Claim(ClaimTypes.Role, "Admin")); // userData.EmpRoleID TODO get roles from db if (jobDeatils != null) { claims.Add(new Claim("RepMgrID", jobDeatils.RepMgrID.ToString())); var reportMngDetails = data.EmployeeDetails.FirstOrDefault(x => x.EmpID == jobDeatils.RepMgrID); if (reportMngDetails != null) { claims.Add(new Claim("RepMgrName", reportMngDetails.EmpName)); } claims.Add(new Claim("DepartmentId", jobDeatils.DeptID.ToString())); claims.Add(new Claim("LocationId", jobDeatils.LocationID.ToString())); } // Setting Claim Identities for OAUTH 2 protocol. ClaimsIdentity oAuthClaimIdentity = new ClaimsIdentity(claims, OAuthDefaults.AuthenticationType); ClaimsIdentity cookiesClaimIdentity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie); // CookieAuthenticationDefaults.AuthenticationType match this in auth.cs(app.UseCookieAuthentication()) AuthenticationProperties properties = CreateProperties(userData.EmpName); AuthenticationTicket ticket = new AuthenticationTicket(oAuthClaimIdentity, properties); context.Validated(ticket); context.Request.Context.Authentication.SignIn(cookiesClaimIdentity); }