public bool AddUserNoTrans(UserOrgDTO model) { var entity = AutoMapperHelper.Map <UserOrgDTO, Org_UserOrg>(model); // chuc danh var jobTitle = GetJobTitles().FirstOrDefault(t => t.Id == entity.JobTitleId); if (jobTitle != null) { entity.JobTitle = jobTitle.Title; } // ten phong ban var orgName = GetAllOrgs().FirstOrDefault(t => t.Id == entity.OrgId); if (orgName != null) { entity.OrgName = orgName.Name; } var result = _repo.Add(entity); _unitOfWork.SaveChanges(); return(true); }
public bool UpdateUserNoTrans(UserOrgDTO entity) { if (entity.FirstKpiDateYM != null && entity.FirstKpiDateYM > 0) { entity.FirstKpiDate = DateTime.ParseExact(entity.FirstKpiDateYM.ToString(), "yyyyMM", System.Globalization.CultureInfo.InvariantCulture); entity.EDCUpdateDate = DateTime.Now; } return(_gridRepository.UpdateUserNoTrans(entity)); }
public bool AddUser(UserOrgDTO entityDTo) { using (var transaction = _unitOfWork.BeginTransaction()) { var entity = AutoMapperHelper.Map <UserOrgDTO, Org_UserOrg>(entityDTo); //var max = _repo.SelectAll().Max(x=>x.Id); //entity.Id = max + 1; var result = _repo.Add(entity); _unitOfWork.SaveChanges(); transaction.Commit(); } return(true); }
public bool UpdateUser(UserOrgDTO entityDTo) { using (var transaction = _unitOfWork.BeginTransaction()) { var entity = AutoMapperHelper.Map <UserOrgDTO, Org_UserOrg>(entityDTo); var user = _repo.SelectWhere(x => x.Id == entity.Id).FirstOrDefault(); AutoMapperHelper.MapSameType <Org_UserOrg>(entity, user, typeof(Org_UserOrg)); _repo.Update(user); _unitOfWork.SaveChanges(); transaction.Commit(); } return(true); }
public bool DeleteUser(UserOrgDTO entity) { return(false); }
public bool UpdateUserNoTrans(UserOrgDTO entityDTo) { var user = _repo.SelectWhere(x => x.Id == entityDTo.Id).FirstOrDefault(); user.UserFullName = entityDTo.UserFullName; user.Status = entityDTo.Status; user.FirstKpiDate = entityDTo.FirstKpiDate; user.KpiType = entityDTo.KpiType; user.Level1ManagerId = entityDTo.Level1ManagerId; user.Level2ManagerId = entityDTo.Level2ManagerId; user.UserName = entityDTo.UserName; user.DOB = entityDTo.DOB; user.StartWorkDate = entityDTo.StartWorkDate; user.Code = entityDTo.Code; user.IdCardNumber = entityDTo.IdCardNumber; user.IdCardDate = entityDTo.IdCardDate; user.IdCardLocation = entityDTo.IdCardLocation; user.IsOrgManager = entityDTo.IsOrgManager; user.UserEmail = entityDTo.UserEmail; user.PhoneNumber = entityDTo.PhoneNumber; var currentOrg = this._orgRepo.SelectWhere(x => x.Id == entityDTo.OrgId).Select(x => new OrganizationDTO { Id = x.Id, Name = x.Name }).FirstOrDefault(); user.OrgId = currentOrg.Id; user.OrgName = currentOrg.Name; // neu cap nhat tu dieu chuyen thì cho cap nhat chuc danh phong ban //if (fromEmpTransfer) //{ // // chuc danh // user.JobTitleId = entityDTo.JobTitleId; // var jobTitle = GetJobTitles().FirstOrDefault(t => t.Id == user.JobTitleId); // if (jobTitle != null) // { // user.JobTitle = jobTitle.Title; // } // // ten phong ban // user.OrgId = entityDTo.OrgId; // var orgName = GetAllOrgs().FirstOrDefault(t => t.Id == user.OrgId); // if (orgName != null) // { // user.OrgName = orgName.Name; // } // this._repo.UpdateByProperties(user, // new List<Expression<Func<Org_UserOrg, object>>> { x => x.UserFullName, x => x.JobTitleId, x => x.OrgId, x => x.Status, x => x.FirstKpiDate, x => x.KpiType // , x => x.Level1ManagerId, x => x.Level2ManagerId, x => x.UserName, x => x.DOB, x => x.StartWorkDate, x => x.Code, x=> x.IsOrgManager // , x => x.IdCardNumber, x => x.IdCardDate, x => x.IdCardLocation, x => x.OrgName, x => x.JobTitle}); //} //else //{ //user.KpiType = "QL"; // cap nhat tinh trang nghi viec UpdateUserStatus(user); this._repo.UpdateByProperties(user, new List <Expression <Func <Org_UserOrg, object> > > { x => x.UserFullName, x => x.Status, x => x.FirstKpiDate, x => x.KpiType, x => x.UserEmail, x => x.PhoneNumber , x => x.Level1ManagerId, x => x.Level2ManagerId, x => x.UserName, x => x.DOB, x => x.StartWorkDate, x => x.Code, x => x.IsOrgManager , x => x.IdCardNumber, x => x.IdCardDate, x => x.IdCardLocation, x => x.OrgId, x => x.OrgName }); //} //_repo.Update(user); _unitOfWork.SaveChanges(); return(true); }
public bool UpdateUser(UserOrgDTO model) { return(_gridRepository.UpdateUser(model)); }
public bool AddUserNoTrans(UserOrgDTO model) { return(_gridRepository.AddUserNoTrans(model)); }
public bool DeleteUser(UserOrgDTO entity) { return(this._gridRepository.DeleteUser(entity)); }