public void PutContact_ShouldFail_WhenDifferentID() { var contactsTestData = new List <EmployeeContact>() { new EmployeeContact { Id = 1, EmployeeId = 2 }, new EmployeeContact { Id = 2, Deleted = true, EmployeeId = 2 }, new EmployeeContact { Id = 3, EmployeeId = 3 } }; var contacts = MockHelper.MockDbSet(contactsTestData); var dbContext = new Mock <IAppDbContext>(); dbContext.Setup(m => m.EmployeeContacts).Returns(contacts.Object); dbContext.Setup(d => d.Set <EmployeeContact>()).Returns(contacts.Object); var factory = new Mock <IDbContextFactory>(); factory.Setup(m => m.CreateDbContext()).Returns(dbContext.Object); IDbContextFactory fac = factory.Object; var controller = new EmployeeContactsController(fac); EmployeeContact contact = new EmployeeContact { Id = 4, EmployeeId = 25 }; var badresult = controller.PutEmployeeContact(999, contact.ToDTO()); Assert.IsInstanceOfType(badresult, typeof(BadRequestResult)); }
public override AccountManagerViewModel DataToViewModel(AccountManager accountManager) { // Получение всех необходимых параметров Employee employee = context.Employees.FirstOrDefault(i => i.Id == accountManager.ManagerId); Account account = context.Accounts.FirstOrDefault(i => i.Id == accountManager.AccountId); Position position = employee.PrimaryPositionId == null ? null : context.Positions.FirstOrDefault(i => i.Id == employee.PrimaryPositionId); bool isPrimary = accountManager.Id == account.PrimaryManagerId; bool isLock = position == null; string positionName = isLock ? string.Empty : position.Name; Func <EmployeeContact, bool> predicate = empCon => empCon.EmployeeId == employee.Id && empCon.ContactType == ContactType.Work; EmployeeContact employeeContact = context.EmployeeContacts.FirstOrDefault(predicate); string phoneNumber = employeeContact?.PhoneNumber; // Возврат результата return(new AccountManagerViewModel() { Id = accountManager.Id, EmployeeId = employee.Id, InitialName = employee.GetIntialsFullName(), IsPrimary = isPrimary, IsLock = isLock, PositionName = positionName, PhoneNumber = phoneNumber }); }
public IHttpActionResult PostEmployeeContact(EmployeeContactDTO employeeContact) { if (employeeContact == null || !ModelState.IsValid) { return(BadRequest(ModelState)); } try { EmployeeContact contact = employeeContact.FromDTO(); UnitOfWork unitOfWork = new UnitOfWork(factory); contact.Id = contact.NewId(unitOfWork); unitOfWork.EmployeeContactsRepository.Insert(contact); unitOfWork.Save(); EmployeeContactDTO dto = unitOfWork.EmployeeContactsRepository.Get(d => d.Id == contact.Id, includeProperties: "ContactType").FirstOrDefault().ToDTO(); return(CreatedAtRoute("GetEmployeeContact", new { id = dto.Id }, dto)); } catch (NotFoundException nfe) { return(NotFound()); } catch (ConflictException ce) { return(Conflict()); } catch (Exception e) { return(BadRequest(e.Message)); } }
public void PutContact_ShouldReturnOk() { var contactsTestData = new List <EmployeeContact>() { new EmployeeContact { Id = 1, EmployeeId = 2 }, new EmployeeContact { Id = 2, Deleted = true, EmployeeId = 2 }, new EmployeeContact { Id = 3, EmployeeId = 3 } }; var contacts = MockHelper.MockDbSet(contactsTestData); var dbContext = new Mock <IAppDbContext>(); dbContext.Setup(m => m.EmployeeContacts).Returns(contacts.Object); dbContext.Setup(d => d.Set <EmployeeContact>()).Returns(contacts.Object); var factory = new Mock <IDbContextFactory>(); factory.Setup(m => m.CreateDbContext()).Returns(dbContext.Object); IDbContextFactory fac = factory.Object; var controller = new GTIWebAPI.Controllers.EmployeeContactsController(fac); EmployeeContact contact = new EmployeeContact { Id = 3, EmployeeId = 25 }; var result = controller.PutEmployeeContact(3, contact.ToDTO()) as OkNegotiatedContentResult <EmployeeContactDTO>; Assert.IsNotNull(result); Assert.AreEqual(3, result.Content.Id); }
public IHttpActionResult DeleteEmployeeContact(int id) { try { UnitOfWork unitOfWork = new UnitOfWork(factory); EmployeeContact employeeContact = unitOfWork.EmployeeContactsRepository.Get(d => d.Id == id, includeProperties: "ContactType").FirstOrDefault(); employeeContact.Deleted = true; unitOfWork.EmployeeContactsRepository.Update(employeeContact); unitOfWork.Save(); EmployeeContactDTO dto = employeeContact.ToDTO(); return(Ok(dto)); } catch (NotFoundException nfe) { return(NotFound()); } catch (ConflictException ce) { return(Conflict()); } catch (Exception e) { return(BadRequest(e.Message)); } }
public void InsertContact(EmployeeContact contact) { if (!_Contacts.ContainsKey(contact.EmpId)) { _Contacts.Add(contact.EmpId, contact); } SaveProfile(); }
public EmpContactItem GetById(int id) { Mapper.CreateMap <EmployeeContact, EmpContactItem>(); EmployeeContact objEmpContct = DBContext.EmployeeContacts.SingleOrDefault(m => m.Id == id); EmpContactItem objContactItem = Mapper.Map <EmpContactItem>(objEmpContct); return(objContactItem); }
public int Update(EmpContactItem model) { Mapper.CreateMap <EmpContactItem, EmployeeContact>(); EmployeeContact objEmpcontact = DBContext.EmployeeContacts.SingleOrDefault(m => m.Id == model.Id); objEmpcontact = Mapper.Map(model, objEmpcontact); return(DBContext.SaveChanges()); }
public ActionResult DeleteConfirmed(int id) { EmployeeContact employeeContact = db.EmployeeContacts.Find(id); db.EmployeeContacts.Remove(employeeContact); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ContactId,firstName,lastName,empTitle,phone,email")] EmployeeContact employeeContact) { if (ModelState.IsValid) { db.Entry(employeeContact).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employeeContact)); }
public ActionResult Create([Bind(Include = "ContactId,firstName,lastName,empTitle,phone,email")] EmployeeContact employeeContact) { if (ModelState.IsValid) { db.EmployeeContacts.Add(employeeContact); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employeeContact)); }
/// <summary> /// 创建一个员工联系方式 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="db">数据库上下文</param> /// <param name="entity">一个员工联系方式</param> /// <returns></returns> public bool Create(ref ValidationErrors validationErrors, EmployeeContact entity) { try { repository.Create(entity); return(true); } catch (Exception ex) { validationErrors.Add(ex.Message); ExceptionsHander.WriteExceptions(ex); } return(false); }
public int Insert(EmpContactItem model) { try { Mapper.CreateMap <EmpContactItem, EmployeeContact>(); EmployeeContact objempContact = Mapper.Map <EmployeeContact>(model); DBContext.EmployeeContacts.Add(objempContact); return(DBContext.SaveChanges()); } catch (Exception ex) { throw ex; } }
// GET: EmployeeContacts/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmployeeContact employeeContact = db.EmployeeContacts.Find(id); if (employeeContact == null) { return(HttpNotFound()); } return(View(employeeContact)); }
protected void PoPuPCO(object sender, DirectEventArgs e) { int id = Convert.ToInt32(e.ExtraParams["id"]); string type = e.ExtraParams["type"]; switch (type) { case "imgEdit": //Step 1 : get the object from the Web Service EmployeeContact entity = GetCOById(id.ToString()); //Step 2 : call setvalues with the retrieved object this.ContactsForm.SetValues(entity); costreet1.Text = entity.address.street1; costreet2.Text = entity.address.street2; copostalCode.Text = entity.address.postalCode; cocity.Text = entity.address.city; coaddressId.Text = entity.address.recordId; FillCOState(); costId.Select(entity.address.stateId); FillCONationality(); conaId.Select(entity.address.countryId); this.EditContactWindow.Title = Resources.Common.EditWindowsTitle; this.EditContactWindow.Show(); break; case "imgDelete": X.Msg.Confirm(Resources.Common.Confirmation, Resources.Common.DeleteOneRecord, new MessageBoxButtonsConfig { Yes = new MessageBoxButtonConfig { //We are call a direct request metho for deleting a record Handler = String.Format("App.direct.DeleteCO({0})", id), Text = Resources.Common.Yes }, No = new MessageBoxButtonConfig { Text = Resources.Common.No } }).Show(); break; default: break; } }
public string SaveData(MindfireEmployeeRegister obj) { MindfireDbContext dbReference = new MindfireDbContext(); string filePath = ""; if (obj.ImageUpload.ContentLength > 0 && obj.ImageUpload != null) { string filename = Path.GetFileName(obj.ImageUpload.FileName); filePath = Path.Combine("\\UploadImage\\", obj.Email + Path.GetExtension(filename)); string directoryPath = Path.Combine(HttpContext.Current.Server.MapPath("~/UploadImage"), obj.Email + Path.GetExtension(filename)); obj.ImageUpload.SaveAs(directoryPath); } var employee = new Employee() { Firstname = obj.Firstname, Lastname = obj.Lastname, Email = obj.Email, Address = obj.Address, Password = Hash.GetHash(obj.Password), EmployeeImage = filePath, }; dbReference.GetEmployeeDetails.Add(employee); for (int i = 0; i < obj.UserContactList.Count(); i++) { EmployeeContact employeeContact = new EmployeeContact(); employeeContact.ContactNumber = obj.ContactNumber[i]; employeeContact.EmployeeId = employee.EmployeeId; employeeContact.ContactTypeId = (int)obj.UserContactList[i]; dbReference.GetContactDetails.Add(employeeContact); } var accessUser = new Access() { EmployeeId = employee.EmployeeId, RoleId = 2 }; dbReference.GetAccessType.Add(accessUser); dbReference.SaveChanges(); return(obj.Email); }
/// <summary> /// 创建联系方式 /// </summary> /// <param name="entity">实体对象</param> /// <returns></returns> public Common.ClientResult.Result Post([FromBody] EmployeeContact entity) { IBLL.IEmployeeContactBLL c_BLL = new EmployeeContactBLL(); Common.ClientResult.Result result = new Common.ClientResult.Result(); if (entity != null && ModelState.IsValid) { entity.State = "启用"; entity.CreateTime = DateTime.Now; entity.CreatePerson = LoginInfo.RealName; //entity.EmployeeId = LoginInfo.UserID; string returnValue = string.Empty; if (c_BLL.Create(ref validationErrors, entity)) { LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",员工银行的信息的Id为" + entity.Id, "员工银行" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.InsertSucceed; return(result); //提示创建成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",员工银行的信息," + returnValue, "员工银行" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.InsertFail + returnValue; return(result); //提示插入失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对 return(result); }
public static int?ConvertSpecialist(EmployeeContact contact) { decimal contactType = contact.ContactType_ID; if (contactType == Specialist.Site) { var pair = SpecialistValueMapper.FirstOrDefault(p => contact.ContactValue.Contains(p.Key)); if (pair.Key != null) { return(pair.Value); } } if (SpecialistIdMapper.ContainsKey(contactType)) { return(SpecialistIdMapper[contactType]); } return(null); }
/// <summary> /// 创建 /// </summary> /// <param name="entity">实体对象</param> /// <returns></returns> public Common.ClientResult.Result Post([FromBody] EmployeeContact entity) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (entity != null && ModelState.IsValid) { //string currentPerson = GetCurrentPerson(); //entity.CreateTime = DateTime.Now; //entity.CreatePerson = currentPerson; string returnValue = string.Empty; if (m_BLL.Create(ref validationErrors, entity)) { LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",员工联系方式的信息的Id为" + entity.Id, "员工联系方式" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.InsertSucceed; return(result); //提示创建成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",员工联系方式的信息," + returnValue, "员工联系方式" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.InsertFail + returnValue; return(result); //提示插入失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对 return(result); }
public void DeleteCO(string index) { try { //Step 1 Code to delete the object from the database EmployeeContact n = new EmployeeContact(); n.recordId = index; PostRequest <EmployeeContact> req = new PostRequest <EmployeeContact>(); req.entity = n; PostResponse <EmployeeContact> res = _employeeService.ChildDelete <EmployeeContact>(req); if (!res.Success) { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, res.Summary).Show(); return; } else { //Step 2 : remove the object from the store contactStore.Remove(index); //Step 3 : Showing a notification for the user Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordDeletedSucc }); } } catch (Exception ex) { //In case of error, showing a message box to the user X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorDeletingRecord).Show(); } }
public IHttpActionResult PutEmployeeContact(int id, EmployeeContactDTO employeeContact) { if (employeeContact == null || !ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != employeeContact.Id) { return(BadRequest()); } try { EmployeeContact contact = employeeContact.FromDTO(); UnitOfWork unitOfWork = new UnitOfWork(factory); unitOfWork.EmployeeContactsRepository.Update(contact); unitOfWork.Save(); EmployeeContactDTO dto = unitOfWork.EmployeeContactsRepository.Get(d => d.Id == id, includeProperties: "ContactType").FirstOrDefault().ToDTO(); return(Ok(dto)); } catch (NotFoundException nfe) { return(NotFound()); } catch (ConflictException ce) { return(Conflict()); } catch (NullReferenceException nre) { return(NotFound()); } catch (Exception e) { return(BadRequest(e.Message)); } }
private List <EmployeeContact> GetEmployeeContacts(string userID) { var userContactList = new List <EmployeeContact>(); var sqlParams = new Dictionary <string, object> { { "@КодСотрудника", userID }, { "@КодТелефоннойСтанцииЗвонящего", "" } }; using (var dbReader = new DBReader(SQLQueries.SP_Сотрудники_Контакты, CommandType.StoredProcedure, CN, sqlParams)) { if (dbReader.HasRows) { while (dbReader.Read()) { var tempUserContact = new EmployeeContact(); tempUserContact.LoadFromDbReader(dbReader); userContactList.Add(tempUserContact); } } } return(userContactList); }
/// <summary> /// 根据ID获取数据模型 /// </summary> /// <param name="id">编号</param> /// <returns></returns> public EmployeeContact Get(int id) { EmployeeContact item = m_BLL.GetById(id); return(item); }
public void DeleteContact(EmployeeContact contact) { _Contacts.Remove(contact.EmpId); SaveProfile(); }
public void UpdateContact(EmployeeContact contact) { _Contacts[contact.EmpId] = contact; SaveProfile(); }
public EmployeeContact[] GetContacts() { EmployeeContact[] contacts = new EmployeeContact[_Contacts.Values.Count]; _Contacts.Values.CopyTo(contacts, 0); return(contacts); }
protected override void Seed(MindfireSolutions.Models.MindfireDbContext context) { List <ContactType> addContact = new List <ContactType>(); addContact.Add(new ContactType() { ContactTypeValue = "Mobile" }); addContact.Add(new ContactType() { ContactTypeValue = "Fax" }); addContact.Add(new ContactType() { ContactTypeValue = "Home" }); addContact.Add(new ContactType() { ContactTypeValue = "Office" }); addContact.Add(new ContactType() { ContactTypeValue = "Landline" }); context.GetContactType.AddRange(addContact); List <Role> addRole = new List <Role>(); addRole.Add(new Role() { RolePosition = "Admin" }); addRole.Add(new Role() { RolePosition = "User" }); context.GetRoleType.AddRange(addRole); Employee addEmployee = new Employee(); addEmployee.Firstname = "Admin"; addEmployee.Lastname = "Sir"; addEmployee.Address = "Mindfire Solutions"; addEmployee.Email = "*****@*****.**"; addEmployee.Password = Hash.GetHash("admin@123"); addEmployee.EmployeeImage = @"\UploadImage\[email protected]"; context.GetEmployeeDetails.Add(addEmployee); EmployeeContact contact = new EmployeeContact(); contact.ContactNumber = "877693273"; contact.ContactTypeDetails = addContact.Single(s => s.ContactTypeValue == "Mobile"); contact.EmployeeDetails = addEmployee; context.GetContactDetails.Add(contact); Access access = new Access(); access.EmployeeUserDetails = addEmployee; access.RoleDetails = addRole.Single(s => s.RolePosition == "Admin"); context.GetAccessType.Add(access); }
public void PostContact_ShouldReturnSameContact() { var contactsTestData = new List <EmployeeContact>() { new EmployeeContact { Id = 1, EmployeeId = 2 }, new EmployeeContact { Id = 2, Deleted = true, EmployeeId = 2 }, new EmployeeContact { Id = 3, EmployeeId = 3 } }; var contacts = MockHelper.MockDbSet(contactsTestData); contacts.Setup(d => d.Find(It.IsAny <object>())).Returns <object[]>((keyValues) => { return(contacts.Object.SingleOrDefault(product => product.Id == (int)keyValues.Single())); }); contacts.Setup(d => d.Add(It.IsAny <EmployeeContact>())).Returns <EmployeeContact>((contact) => { contactsTestData.Add(contact); contacts = MockHelper.MockDbSet(contactsTestData); return(contact); }); var dbContext = new Mock <IAppDbContext>(); dbContext.Setup(m => m.EmployeeContacts).Returns(contacts.Object); dbContext.Setup(d => d.Set <EmployeeContact>()).Returns(contacts.Object); dbContext.Setup(d => d.SaveChanges()).Returns(0); dbContext.Setup(d => d.ExecuteStoredProcedure <int>(It.IsAny <string>(), It.IsAny <object[]>())) .Returns <string, object[]>((query, parameters) => { List <int> list = new List <int>(); if (query.Contains("NewTableId")) { int i = contacts.Object.Max(d => d.Id) + 1; list.Add(i); } else { list.Add(0); } return(list); }); var factory = new Mock <IDbContextFactory>(); factory.Setup(m => m.CreateDbContext()).Returns(dbContext.Object); IDbContextFactory fac = factory.Object; var controller = new EmployeeContactsController(fac); var item = new EmployeeContact { Id = 4, EmployeeId = 25, ContactTypeId = 3 }; var result = controller.PostEmployeeContact(item.ToDTO()) as CreatedAtRouteNegotiatedContentResult <EmployeeContactDTO>; Assert.IsNotNull(result); Assert.AreEqual(result.RouteName, "GetEmployeeContact"); Assert.AreEqual(result.RouteValues["id"], result.Content.Id); Assert.AreEqual(result.Content.ContactTypeId, item.ContactTypeId); }
// DELETE api/<controller>/5 /// <summary> /// 删除 /// </summary> /// <param name="collection"></param> /// <returns></returns> //public Common.ClientResult.Result Delete(string query) //{ // IBLL.IEmployeeBLL m_BLL = new EmployeeBLL(); // Common.ClientResult.Result result = new Common.ClientResult.Result(); // string returnValue = string.Empty; // int[] deleteId = Array.ConvertAll<string, int>(query.Split(','), delegate(string s) { return int.Parse(s); }); // if (deleteId != null && deleteId.Length > 0) // { // if (m_BLL.DeleteCollection(ref validationErrors, deleteId)) // { // LogClassModels.WriteServiceLog(Suggestion.DeleteSucceed + ",信息的Id为" + string.Join(",", deleteId), "消息" // );//删除成功,写入日志 // result.Code = Common.ClientCode.Succeed; // result.Message = Suggestion.DeleteSucceed; // } // else // { // if (validationErrors != null && validationErrors.Count > 0) // { // validationErrors.All(a => // { // returnValue += a.ErrorMessage; // return true; // }); // } // LogClassModels.WriteServiceLog(Suggestion.DeleteFail + ",信息的Id为" + string.Join(",", deleteId) + "," + returnValue, "消息" // );//删除失败,写入日志 // result.Code = Common.ClientCode.Fail; // result.Message = Suggestion.DeleteFail + returnValue; // } // } // return result; //} /// <summary> /// 创建 /// </summary> /// <param name="entity">实体对象</param> /// <returns></returns> //public Common.ClientResult.Result Post([FromBody]Employee entity) //{ // IBLL.IEmployeeBLL m_BLL = new EmployeeBLL(); // Common.ClientResult.Result result = new Common.ClientResult.Result(); // if (entity != null && ModelState.IsValid) // { // //string currentPerson = GetCurrentPerson(); // //entity.CreateTime = DateTime.Now; // //entity.CreatePerson = currentPerson; // string returnValue = string.Empty; // if (m_BLL.Create(ref validationErrors, entity)) // { // LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",员工的信息的Id为" + entity.Id, "员工" // );//写入日志 // result.Code = Common.ClientCode.Succeed; // result.Message = Suggestion.InsertSucceed; // return result; //提示创建成功 // } // else // { // if (validationErrors != null && validationErrors.Count > 0) // { // validationErrors.All(a => // { // returnValue += a.ErrorMessage; // return true; // }); // } // LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",员工的信息," + returnValue, "员工" // );//写入日志 // result.Code = Common.ClientCode.Fail; // result.Message = Suggestion.InsertFail + returnValue; // return result; //提示插入失败 // } // } // result.Code = Common.ClientCode.FindNull; // result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对 // return result; //} /// <summary> /// 添加 /// </summary> /// <param name="entity"></param> /// <returns></returns> public Common.ClientResult.Result Create([FromBody] EmployeeInfo entity) { IBLL.IEmployeeBLL m_BLL = new EmployeeBLL(); Common.ClientResult.Result result = new Common.ClientResult.Result(); #region 验证 //if (entity.CertificateType == null) //{ // result.Code = Common.ClientCode.FindNull; // result.Message = "请选择证件类型"; // return result; //提示输入的数据的格式不对 //} //if (entity.Sex == null) //{ // result.Code = Common.ClientCode.FindNull; // result.Message = "请选择性别"; // return result; //提示输入的数据的格式不对 //} //if (entity.AccountType == null) //{ // result.Code = Common.ClientCode.FindNull; // result.Message = "请选择户口类型"; // return result; //提示输入的数据的格式不对 //} //if (entity.CertificateType == "居民身份证") //{ // string number = entity.BasicInfo.CertificateNumber; // if (Common.CardCommon.CheckCardID18(number) == false) // { // result.Code = Common.ClientCode.FindNull; // result.Message = "证件号不正确请重新输入"; // return result; //提示输入的数据的格式不对 // } //} //if (entity.CompanyId==0) //{ // result.Code = Common.ClientCode.FindNull; // result.Message = "请选择所属公司"; // return result; //提示输入的数据的格式不对 //} //if (string.IsNullOrEmpty(entity.Citys)) //{ // result.Code = Common.ClientCode.FindNull; // result.Message = "请选择社保缴纳地"; // return result; //提示输入的数据的格式不对 //} //if (entity.PoliceAccountNatureId == 0) //{ // result.Code = Common.ClientCode.FindNull; // result.Message = "请选择户口性质"; // return result; //提示输入的数据的格式不对 //} #endregion //if (entity != null && ModelState.IsValid) //{ Employee baseModel = entity.BasicInfo; //基本信息 baseModel.AccountType = entity.AccountType; baseModel.CertificateType = entity.CertificateType; baseModel.Sex = entity.Sex; baseModel.CreateTime = DateTime.Now; baseModel.CreatePerson = LoginInfo.RealName; EmployeeContact contact = entity.empContacts; contact.CreatePerson = LoginInfo.RealName; contact.CreateTime = DateTime.Now; EmployeeBank bank = entity.empBank; if (bank.AccountName == null && bank.Bank == null && bank.BranchBank == null && bank.Account == null) { bank = null; } else { bank.CreatePerson = LoginInfo.RealName; bank.CreateTime = DateTime.Now; } CompanyEmployeeRelation relation = new CompanyEmployeeRelation(); relation.CityId = entity.Citys; relation.State = "在职"; relation.CompanyId = entity.CompanyId; relation.CreateTime = DateTime.Now; relation.CreatePerson = LoginInfo.RealName; relation.Station = entity.Station; relation.PoliceAccountNatureId = entity.PoliceAccountNatureId; string returnValue = string.Empty; if (m_BLL.EmployeeAdd(ref validationErrors, baseModel, contact, bank, relation)) { //LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",客户_企业信息_待审核的信息的Id为" + entity.ID, "客户_企业信息_待审核" //);//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.InsertSucceed; return(result); //提示创建成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } //LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",客户_企业信息_待审核的信息," + returnValue, "客户_企业信息_待审核" // );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.InsertFail + returnValue; return(result); //提示插入失败 } //} result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对 return(result); }
public static EmployeeContactDto ToDto(this EmployeeContact entity) { Init(); return(Mapper.Map <EmployeeContactDto>(entity)); }