/// <summary> /// To save new Employee /// </summary> /// <param name="employee">Employee Details of new Employee.</param> /// <returns>It returns true if Employee successfully added.</returns> public ResultStatus SaveEmployee(LicenseManagementMVC.BusinessEntities.Employee employee) { try { using (LicenseManagementMVCEntities salesDal = new LicenseManagementMVCEntities()){ Data.Model.Employee emp = new Data.Model.Employee() { FirstName = employee.FirstName, LastName = employee.LastName, Email = employee.Email, Password = new LoginBusinessLayer().EncodePassword(employee.Password), LocationId = employee.LocationId, RoleId = employee.RoleId, IsReleased = false, ReleaseDate = null, JoiningDate = employee.JoiningDate ?? DateTime.Now }; if (new LicenseManagementMVCEntities().Employees.Any(o => o.Email == emp.Email)) { return(ResultStatus.AlreadyExist); } salesDal.Employees.Add(emp); salesDal.SaveChanges(); return(ResultStatus.Success); } }catch (Exception exp) { //TODO return(ResultStatus.ConnectionError); } }
/// <summary> /// Get Employee data according to employee Id. /// </summary> /// <returns>Employee properties</returns> public Business.Employee FetchEmployeeDetail(int id) { using (Data.Model.LicenseManagementMVCEntities obj = new LicenseManagementMVCEntities()) { var emp = from u in obj.Employees where (u.EmployeeId == id) select u; var x = emp.SingleOrDefault(); Business.Employee empDetail = new Business.Employee() { FirstName = x.FirstName, LastName = x.LastName, Email = x.Email, LocationId = x.LocationId, RoleId = x.RoleId, JoiningDate = x.JoiningDate, ReleaseDate = x.ReleaseDate, IsReleased = x.IsReleased }; return(empDetail); } }