public int Insert(PersonDto person) { var newId = MockDb.MockDb.Persons.Max(r => r.Id) + 1; var newItem = new MockDb.PersonData { Id = newId, FirstName = person.FirstName, LastName = person.LastName }; MockDb.MockDb.Persons.Add(newItem); return newId; }
public int SaveList(PersonDto[] people, string dataFilePath) { try { var json = JsonConvert.SerializeObject(people); File.WriteAllText(dataFilePath, json); return 1; } catch { return -1; } // TODO - structured exception handling, logging of errors ... }
public PersonDto UpdatePerson(int id, PersonDto personDto) { var personFind = _personRepository.GetById(id); personFind.FavouriteColours.Clear(); if (personDto.FavouriteColours != null) { foreach (var colourId in personDto.FavouriteColours) { var colour = _colourService.GetById(colourId); personFind.FavouriteColours.Add(colour); } } personFind.IsAuthorised = personDto.IsAuthorised; personFind.IsEnabled = personDto.IsEnabled; personFind.IsValid = personDto.IsValid; _personRepository.SaveChanges(); return personDto; }
public EditPersonModalViewModel(PersonDto person) { person.MapTo(this); }
public Task <PersonDto> SaveAsync(PersonDto value) { throw new System.NotImplementedException(); }
public string CreatePerson(PacientCustom data, int userId, int nodeId) { try { DatabaseContext cnx = new DatabaseContext(); var newId = new Common.Utils().GetPrimaryKey(nodeId, 8, "PP"); PersonDto oPersonDto = new PersonDto(); oPersonDto.v_PersonId = newId; oPersonDto.v_FirstName = data.v_FirstName; oPersonDto.v_FirstLastName = data.v_FirstLastName; oPersonDto.v_SecondLastName = data.v_SecondLastName; oPersonDto.i_DocTypeId = data.i_DocTypeId; oPersonDto.v_DocNumber = data.v_DocNumber; oPersonDto.d_Birthdate = data.d_Birthdate; oPersonDto.v_BirthPlace = data.v_BirthPlace; oPersonDto.i_SexTypeId = data.i_SexTypeId; oPersonDto.i_MaritalStatusId = data.i_MaritalStatusId; oPersonDto.i_LevelOfId = data.i_LevelOfId; oPersonDto.v_TelephoneNumber = data.v_TelephoneNumber; oPersonDto.v_AdressLocation = data.v_AdressLocation; oPersonDto.v_GeografyLocationId = data.v_GeografyLocationId; oPersonDto.v_ContactName = data.v_ContactName; oPersonDto.v_EmergencyPhone = data.v_EmergencyPhone; oPersonDto.b_PersonImage = data.b_PersonImage; oPersonDto.v_Mail = data.v_Mail; oPersonDto.i_BloodGroupId = data.i_BloodGroupId; oPersonDto.i_BloodFactorId = data.i_BloodFactorId; oPersonDto.b_FingerPrintTemplate = data.b_FingerPrintTemplate; oPersonDto.b_RubricImage = data.b_RubricImage; oPersonDto.b_FingerPrintImage = data.b_FingerPrintImage; oPersonDto.t_RubricImageText = data.t_RubricImageText; oPersonDto.v_CurrentOccupation = data.v_CurrentOccupation; oPersonDto.i_DepartmentId = data.i_DepartmentId; oPersonDto.i_ProvinceId = data.i_ProvinceId; oPersonDto.i_DistrictId = data.i_DistrictId; oPersonDto.i_ResidenceInWorkplaceId = data.i_ResidenceInWorkplaceId; oPersonDto.v_ResidenceTimeInWorkplace = data.v_ResidenceTimeInWorkplace; oPersonDto.i_TypeOfInsuranceId = data.i_TypeOfInsuranceId; oPersonDto.i_NumberLivingChildren = data.i_NumberLivingChildren; oPersonDto.i_NumberDependentChildren = data.i_NumberDependentChildren; oPersonDto.i_OccupationTypeId = data.i_OccupationTypeId; oPersonDto.v_OwnerName = data.v_OwnerName; oPersonDto.i_NumberLiveChildren = data.i_NumberLiveChildren; oPersonDto.i_NumberDeadChildren = data.i_NumberDeadChildren; oPersonDto.i_IsDeleted = 0; oPersonDto.i_InsertNodeId = data.i_InsertNodeId; oPersonDto.i_UpdateNodeId = data.i_UpdateNodeId; oPersonDto.i_Relationship = data.i_Relationship; oPersonDto.v_ExploitedMineral = data.v_ExploitedMineral; oPersonDto.i_AltitudeWorkId = data.i_AltitudeWorkId; oPersonDto.i_PlaceWorkId = data.i_PlaceWorkId; oPersonDto.v_NroPoliza = data.v_NroPoliza; oPersonDto.v_Deducible = data.v_Deducible; oPersonDto.i_NroHermanos = data.i_NroHermanos; oPersonDto.v_Password = data.v_Password; oPersonDto.v_Procedencia = data.v_Procedencia; oPersonDto.v_CentroEducativo = data.v_CentroEducativo; oPersonDto.v_Religion = data.v_Religion; oPersonDto.v_Nacionalidad = data.v_Nacionalidad; oPersonDto.v_ResidenciaAnterior = data.v_ResidenciaAnterior; oPersonDto.v_Subs = data.v_Subs; oPersonDto.v_ComentaryUpdate = data.v_ComentaryUpdate; //Auditoria oPersonDto.i_InsertUserId = userId; oPersonDto.d_InsertDate = DateTime.Now; cnx.Person.Add(oPersonDto); cnx.SaveChanges(); return(newId); } catch (Exception ex) { return(null); } }
public IActionResult Post([FromBody] PersonDto person) { person.Id = people.Count() + 1; ((List <PersonDto>)people).Add(person); return(Ok()); }
private void DisplaySuccess( Rock.Model.UserLogin user ) { FormsAuthentication.SignOut(); Rock.Security.Authorization.SetAuthCookie( tbUserName.Text, false, false ); if ( user != null && user.PersonId.HasValue ) { PersonService personService = new PersonService(); Person person = personService.Get( user.PersonId.Value ); if ( person != null ) { var mergeObjects = new Dictionary<string, object>(); mergeObjects.Add( "ConfirmAccountUrl", RootPath + "ConfirmAccount" ); var personDictionary = new PersonDto( person ).ToDictionary(); personDictionary.Add("FirstName", person.FirstName); mergeObjects.Add( "Person", personDictionary ); mergeObjects.Add( "User", new UserLoginDto( user ).ToDictionary() ); var recipients = new Dictionary<string, Dictionary<string, object>>(); recipients.Add( person.Email, mergeObjects ); Email email = new Email( Rock.SystemGuid.EmailTemplate.SECURITY_ACCOUNT_CREATED ); email.Send( recipients ); lSuccessCaption.Text = AttributeValue( "SuccessCaption" ); if ( lSuccessCaption.Text.Contains( "{0}" ) ) lSuccessCaption.Text = string.Format( lSuccessCaption.Text, person.FirstName ); ShowPanel( 5 ); } else ShowErrorMessage( "Invalid Person" ); } else ShowErrorMessage( "Invalid User" ); }
public async Task <ActionResult <IEnumerable <PersonDto> > > GetSimiliarPersons([FromBody] PersonDto dataDto) { var data = _mapper.MapFromDto <PersonDto, Person>(dataDto); var result = await _service.GetSimiliarPersonsAsync(data); return(new ObjectResult(new { PersonsGetSimiliar = _mapper.MapToDto <Person, PersonDto>(result) })); }
public void Act() { dto = this.mapper.Map(this.person); }
public async Task CreatePersonAsync(PersonDto person) { await _personRepository.CreatePersonAsync(person); }
public PersonDto PostPerson([Required, FromBody] PersonDto personDto) { personDto.FirstName += " portugal"; return(personDto); }
public void Update(PersonDto person) { var updatedItem = MockDb.MockDb.Persons.Where(x => x.Id == person.Id).Single(); updatedItem.FirstName = person.FirstName; updatedItem.LastName = person.LastName; }
public static void ShowPersonsByQuery() { var myQueryDto = new GetPersonByEmploymentNumberQueryDto(); //myQueryDto.PersonId = @"4CBBF982-0F91-4451-B742-A42F00F0EE98"; myQueryDto.EmploymentNumber = @"4319"; var t = teleoptiServiceApplication.OrganizationService.GetPersonsByQuery(myQueryDto).Where(p => !p.IsDeleted); //teleoptiServiceApplication.OrganizationService; PersonDto[] result = new PersonDto[t.Count()]; int i = 0; foreach (var item in t) { Utilities.WriteLog(String.Format(String.Format(@"{0} {1} {2}", i++, item.EmploymentNumber, item.LastName))); } }
private static PersonDto[] GetPersonByQuery() { var myQueryDto = new GetPersonByUserNameQueryDto(); //myQueryDto.PersonId = @"4CBBF982-0F91-4451-B742-A42F00F0EE98"; myQueryDto.UserName = @"Yuri"; var t = teleoptiServiceApplication.OrganizationService.GetPersonsByQuery(myQueryDto).Where(p => !p.IsDeleted); //teleoptiServiceApplication.OrganizationService; PersonDto[] result = new PersonDto[t.Count()]; int i = 0; foreach (var item in t) { result[i] = item; } return result; }
public AddPersonCommand(PersonDto personDto) { PersonDto = personDto; }
public async Task <bool> Delete([FromBody] PersonDto input) { var result = await _personService.Delete(input); return(result); }
public void BizAction(PersonDto inputData) { var person = _dbAccess.GetPerson(inputData.Id); if (person == null) { AddError("Could not find the person. Someone entering illegal ids?"); } if (string.IsNullOrWhiteSpace(inputData.FirstName)) { AddError("First Name is Required."); } if (string.IsNullOrWhiteSpace(inputData.LastName)) { AddError("Last Name is Required."); } if (string.IsNullOrWhiteSpace(inputData.NationalId)) { AddError("National Id is Required."); } if (string.IsNullOrWhiteSpace(inputData.MobileNumber)) { AddError("Mobile Number is Required."); } if (!inputData.ProjectIds.Any()) { AddError("Please select some project."); } IStatusGeneric status = person.UpdatePerson(inputData.FirstName, inputData.LastName, inputData.NationalId, inputData.MobileNumber);; if (!HasErrors) { var projects = _projectAccess.GetProjectForPerson(person.Id); foreach (var p in inputData.ProjectIds) { if (projects.Any()) { var cp = projects.SingleOrDefault(s => s.Id == p); if (cp == null) { person.AddProjectToperson(p); } } else { person.AddProjectToperson(p); } } foreach (var p in projects) { var cp = inputData.ProjectIds.SingleOrDefault(s => s == p.Id); if (cp == default(Guid)) { var personProejct = p.AgentsLink.First(s => s.PersonId == person.Id && s.ProjectId == p.Id); person.RemoveProjectFromperson(personProejct); } } } CombineErrors(status); Message = $"person is update: {person.ToString()}."; }
private void DisplayConfirmation( int personId ) { PersonService personService = new PersonService(); Person person = personService.Get(personId); if (person != null) { Rock.Model.UserLogin user = CreateUser( person, false ); var mergeObjects = new Dictionary<string, object>(); mergeObjects.Add( "ConfirmAccountUrl", RootPath + "ConfirmAccount" ); var personDictionary = new PersonDto( person ).ToDictionary(); personDictionary.Add( "FirstName", person.FirstName ); mergeObjects.Add( "Person", personDictionary ); mergeObjects.Add( "User", new UserLoginDto( user ).ToDictionary() ); var recipients = new Dictionary<string, Dictionary<string, object>>(); recipients.Add( person.Email, mergeObjects ); Email email = new Email( Rock.SystemGuid.EmailTemplate.SECURITY_CONFIRM_ACCOUNT ); email.Send( recipients ); ShowPanel( 4 ); } else ShowErrorMessage("Invalid Person"); }
public async Task <IActionResult> Create(PersonDto personDto) { await _personService.AddAsync(_mapper.Map <Person>(personDto)); return(RedirectToAction("Index")); }
protected override void Because_of() { _destination = Mapper.Map<PersonDto>(new Person { PrefixNamePostfix = "John" }); }
public IActionResult Update(PersonDto personDto) { _personService.Update(_mapper.Map <Person>(personDto)); return(RedirectToAction("Index")); }
public Agent CreateAndAddAgent(PersonDto personDto) { Agent agent = new Agent(personDto, this); _agentColl.Add(agent); return agent; }
public ActionResult Politician(HttpPostedFileBase mainPic, HttpPostedFileBase listButtonPic, HttpPostedFileBase smallButtonPic, PersonDto personDto) { var personRepo = new PersonRepository(); var languageManager = new LanguageManager(); var parliamentManager = new ParliamentManager(); Person person; if (personDto.Id == 0) { if (personDto.GenericName.Trim() == personDto.GenericPost.Trim()) { TempData["Notifications"] = $"Please select different strings for post and name."; return(View("Politician", personDto)); } if (LanguageHelper.IsInUse(personDto.GenericName)) { TempData["Notifications"] = $"Name {personDto.GenericName} is already used in dictionary. Please select another one."; return(View("Politician", personDto)); } if (LanguageHelper.IsInUse(personDto.GenericPost)) { TempData["Notifications"] = $"Post {personDto.GenericPost} is already used in dictionary. Please select another one."; return(View("Politician", personDto)); } person = new Person(); var firstPersonInList = personRepo.GetAll().OrderByDescending(p => p.Id).FirstOrDefault(); if (firstPersonInList == null) { personDto.Id = 1; } else { personDto.Id = firstPersonInList.Id + 1; } TempData["Notifications"] = "Added new politician..."; } else { person = personRepo.Get(personDto.Id); TempData["Notifications"] = "Saved..."; } parliamentManager.FillImages(mainPic, listButtonPic, smallButtonPic, personDto, person); personDto.Tracks = person.Tracks; var updatedPerson = PersonMapper.MapPersonDto(personDto); languageManager.SaveTranslations(personDto); personRepo.Upsert(updatedPerson); return(RedirectToAction("Politician", new { id = personDto.Id })); }
static void Main(string[] args) { //This goes in the startup var automapperConfig = new AutoMapperConfig().RegisterMappings(); //Every single member has correlation with destination type. //It may not be the right one (since there are always exception cases), //but it at least tests that every property is moved from source type to destination. //will throw exception if not valid. automapperConfig.AssertConfigurationIsValid(); //Get foo and bar entities from database var fooEntity = new FooEntity() { EmployeeFName = "Foo", EmployeeLName = "Fooster" }; var barEntity = new BarEntity() { PersonFirstName = "Bar", PersonLastName = "Cluster" }; // auto map Entity to DTO var dtoFooModel = Mapper.Map(fooEntity, new FooDto(), typeof(FooEntity), typeof(DTO.FooDto)); var dtoBarModel = Mapper.Map(barEntity, new BarDto(), typeof(BarEntity), typeof(DTO.BarDto)); // Auto Map DTO Back to Entities var fooDTOFromUI = new FooDto() { EmployeeFName = "FooBackToEntity", EmployeeLName = "From Foo DTO" }; var barDTOFromUI = new BarDto() { PersonFName = "BarBackToEntity", PersonLName = "FROM Bar DTO" }; var entityFooModel = Mapper.Map(fooDTOFromUI, new FooEntity(), typeof(FooDto), typeof(FooEntity)); var entityBarModel = Mapper.Map(barDTOFromUI, new BarEntity(), typeof(BarDto), typeof(BarEntity)); //Get AddressEntity from database var addressEntity = new AddressEntity() { Street = "1751 Granger Cir", City = "Castle Rock", State = "CO", Zip = "80109" }; // auto map Entity to DTO var addressDto = new AddressDisplayOnlyDto(); Mapper.Map(addressEntity, addressDto, typeof(AddressEntity), typeof(AddressDisplayOnlyDto)); var p = addressDto.CompleteAddress; Console.WriteLine(p); Console.ReadKey(); //Get Person and Address entity from database PersonEntity personEntity = new PersonEntity() { FirstName = "Eric", LastName = "Norton", PersonAddress = addressEntity }; //Map person entity and personEntity.Address to personDto var dtoPersonModel = Mapper.Map(personEntity, new PersonDto(), typeof(PersonEntity), typeof(PersonDto)); //Get Person DTO from UI PersonDto personDto = new PersonDto() { FName = "Eric", LName = "Nordin", Street = "345 West Green St", City = "Castle Rock", State = "CO", ZipCode = "44565" }; //Get Person DTO from UI and map back to person entity and address entity PersonEntity entityPersonModel = Mapper.Map(personDto, new PersonEntity(), typeof(PersonDto), typeof(PersonEntity)) as PersonEntity; }
public Person MapToBo(PersonDto personDto) { throw new NotImplementedException(); }
public MessageCustom AddSystemUserExternal(PersonDto pobjPerson, ProfessionalBE pobjProfessional, SystemUserDto pobjSystemUser, List <ProtocolSystemUserBE> ListProtocolSystemUser, int userId, int nodeId) { //mon.IsActive = true; string newId = string.Empty; int systemUserId = -1; MessageCustom msg = new MessageCustom(); OperationResult objOperationResult = new OperationResult(); try { using (var ts = new TransactionScope()) { #region Validations // Validar el DNI de la persona DatabaseContext dbContext = new DatabaseContext(); if (pobjPerson != null) { if (pobjSystemUser.i_SystemUserId == -1) //-1 es nuevo { // Grabar Persona var _recordCount1 = GetPersonCount(pobjPerson.v_DocNumber); if (_recordCount1 != 0) { throw new Exception("El número de documento <strong>" + pobjPerson.v_DocNumber + "</strong> ya se encuentra registrado. Por favor ingrese otro número de documento."); } pobjPerson.d_InsertDate = DateTime.Now; pobjPerson.i_InsertUserId = userId; pobjPerson.i_IsDeleted = 0; // Autogeneramos el Pk de la tabla newId = new Common.Utils().GetPrimaryKey(nodeId, 8, "PP"); pobjPerson.v_PersonId = newId; dbContext.Person.Add(pobjPerson); dbContext.SaveChanges(); // Grabar Profesional pobjProfessional.v_PersonId = pobjPerson.v_PersonId; bool resultProf = AddProfessional(pobjProfessional, userId, nodeId); if (!resultProf) { throw new Exception("Sucedió un error al guardar el profesional, por favor actualice la pagina y vuelva a intentar"); } } else {//actualiza var objPerson = dbContext.Person.Where(x => x.v_PersonId == pobjPerson.v_PersonId).FirstOrDefault(); objPerson.v_FirstName = pobjPerson.v_FirstName; objPerson.v_FirstLastName = pobjPerson.v_FirstLastName; objPerson.v_SecondLastName = pobjPerson.v_SecondLastName; objPerson.i_DocTypeId = pobjPerson.i_DocTypeId; objPerson.v_DocNumber = pobjPerson.v_DocNumber; objPerson.i_SexTypeId = pobjPerson.i_SexTypeId; objPerson.i_MaritalStatusId = pobjPerson.i_MaritalStatusId; objPerson.i_LevelOfId = pobjPerson.i_LevelOfId; objPerson.v_Mail = pobjPerson.v_Mail; objPerson.v_BirthPlace = pobjPerson.v_BirthPlace; objPerson.v_TelephoneNumber = pobjPerson.v_TelephoneNumber; objPerson.d_Birthdate = pobjPerson.d_Birthdate; objPerson.v_AdressLocation = pobjPerson.v_AdressLocation; objPerson.i_UpdateUserId = userId; objPerson.d_UpdateDate = DateTime.Now; dbContext.SaveChanges(); var objProfessional = dbContext.Professional.Where(x => x.v_PersonId == pobjPerson.v_PersonId).FirstOrDefault(); objProfessional.i_ProfessionId = pobjProfessional.i_ProfessionId; objProfessional.v_ProfessionalCode = pobjProfessional.v_ProfessionalCode; objProfessional.v_ProfessionalInformation = pobjProfessional.v_ProfessionalInformation; objProfessional.i_UpdateUserId = userId; objProfessional.d_UpdateDate = DateTime.Now; dbContext.SaveChanges(); } } // Validar existencia de UserName en la BD if (pobjSystemUser != null) { if (pobjSystemUser.i_SystemUserId == -1) { OperationResult objOperationResult7 = new OperationResult(); var _recordCount2 = new SecurityDal().GetSystemUserCount(pobjSystemUser.v_UserName); if (_recordCount2 != 0) { throw new Exception("El nombre de usuario <strong>" + pobjSystemUser.v_UserName + "</strong> ya se encuentra registrado.<br> Por favor ingrese otro nombre de usuario."); } } } #endregion // Grabar Usuario if (pobjSystemUser != null) { if (pobjSystemUser.i_SystemUserId == -1)//-1 es nuevo { pobjSystemUser.v_PersonId = pobjPerson.v_PersonId; pobjSystemUser.i_SystemUserTypeId = (int)SystemUserTypeId.External; pobjSystemUser.i_RolVentaId = -1; pobjSystemUser.v_SystemUserByOrganizationId = ListProtocolSystemUser != null?OrganizationDal.GetOrganizationIdByProtocolId(ListProtocolSystemUser[0].v_ProtocolId) : ""; systemUserId = new SecurityDal().AddSystemUSer(pobjSystemUser, userId, nodeId); if (systemUserId == -1) { throw new Exception("Sucedió un error al guardar el usuario, por favor actualice la pagina y vuelva a intentar"); } } else {//actualiza var objUser = dbContext.SystemUser.Where(x => x.i_SystemUserId == pobjSystemUser.i_SystemUserId).FirstOrDefault(); objUser.v_UserName = pobjSystemUser.v_UserName; objUser.v_Password = pobjSystemUser.v_Password; objUser.d_ExpireDate = pobjSystemUser.d_ExpireDate; objUser.i_UpdateUserId = userId; objUser.d_UpdateDate = DateTime.Now; systemUserId = objUser.i_SystemUserId; dbContext.SaveChanges(); } } #region GRABA ProtocolSystemUser if (ListProtocolSystemUser != null) { if (pobjSystemUser.i_SystemUserId == -1)//-1 es nuevo { bool resultProt = new ProtocolSystemUserDal().AddProtocolSystemUser(ListProtocolSystemUser, systemUserId, userId, nodeId); if (!resultProt) { throw new Exception("Sucedió un error al guardar los protocolos del usuario, por favor actualice la pagina y vuelva a intentar"); } } else //actualiza { bool deletedProt = ProtocolSystemUserDal.DeletedProtocolSystemUser(systemUserId, userId); if (!deletedProt) { throw new Exception("Sucedió un error al actualizar los protocolos del usuario, por favor actualice la pagina y vuelva a intentar"); } bool resultProt = new ProtocolSystemUserDal().AddProtocolSystemUser(ListProtocolSystemUser, systemUserId, userId, nodeId); if (!resultProt) { throw new Exception("Sucedió un error al actualizar los protocolos del usuario, por favor actualice la pagina y vuelva a intentar"); } } } #endregion msg.Error = false; msg.Status = (int)HttpStatusCode.Created; msg.Message = "Se guardó correctamente"; ts.Complete(); } return(msg); } catch (Exception ex) { msg.Error = true; msg.Status = (int)HttpStatusCode.BadRequest; msg.Message = ex.Message; return(msg); } }
public bool PersonAlreadyVotedToday(PersonDto person) { var restaurants = _restaurantRepository.GetAll(); return(restaurants.Any(x => x.Votes.Any(y => y.Person.PersonId == person.PersonId && y.DateTimeVote.Date == DateTime.Now.Date))); }
public void AddPerson(PersonDto person) { Persons.Add(person); }
public Agent(PersonDto personDto, Team team) { _personDto = personDto; _team = team; }
public IHttpActionResult SignUp(UserDto user) { PersonDto person = user.Person; return(Ok()); }
public void Create(PersonDto config) { var entity = config.MapTo <PersonEntity>(); //entity.PersonUUID = Guid.NewGuid().ToString("N"); if (Utils.IsDateTime(config.ValidFrom)) { entity.ValidFrom = Convert.ToDateTime(config.ValidFrom); } if (Utils.IsDateTime(config.ValidTo)) { entity.ValidTo = Convert.ToDateTime(config.ValidTo); } else { if (config.ValidTo == "长期") { entity.ValidTo = DateTime.MaxValue; } } //保存图片 String Tpath = "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/"; var parentPath = HostingEnvironment.MapPath("~/Upload"); string FilePath = parentPath + "/" + Tpath + "/"; if (config.CertificateIIMG != null && config.CertificateIIMG.Length > 0) { try { if (!Directory.Exists(FilePath)) { Directory.CreateDirectory(FilePath); } Image img = ImgUtil.BytToImg(config.CertificateIIMG); string _ImageExtension = ImgUtil.GetImageExtension(img); string FileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "." + _ImageExtension; var imgFullPath = Path.Combine(FilePath, FileName); img.Save(imgFullPath); entity.CertificateIPic = "Upload/" + Tpath + "/" + FileName; } catch (Exception ex) { Log.Error(ex, "图片上传失败"); } } if (config.IDCardImg != null && config.IDCardImg.Length > 0) { try { if (!Directory.Exists(FilePath)) { Directory.CreateDirectory(FilePath); } Image img = ImgUtil.BytToImg(config.IDCardImg); string _ImageExtension = ImgUtil.GetImageExtension(img); string FileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "." + _ImageExtension; var imgFullPath = Path.Combine(FilePath, FileName); img.Save(imgFullPath); entity.IDCardPic = "Upload/" + Tpath + "/" + FileName; } catch (Exception ex) { Log.Error(ex, "保存图片失败"); } } if (config.FaceImg != null && config.FaceImg.Length > 0) { try { if (!Directory.Exists(FilePath)) { Directory.CreateDirectory(FilePath); } Image img = ImgUtil.BytToImg(config.FaceImg); string _ImageExtension = ImgUtil.GetImageExtension(img); string FileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "." + _ImageExtension; var imgFullPath = Path.Combine(FilePath, FileName); img.Save(imgFullPath); entity.FacePic = "Upload/" + Tpath + "/" + FileName; } catch (Exception ex) { Log.Error(ex, "保存图片失败"); } } entity.CreateTime = DateTime.Now; entity.Deleted = false; entity.IsBasicInfo = true; entity.IsVerified = false; entity.IsLived = 0; entity.IsRenter = false; entity.SyncStatus = false; entity.SyncVersion = 0; _personRepository.Insert(entity); Synchronization(entity); }
public async Task <IActionResult> Save(PersonDto personDto) { var newPerson = await _personService.AddAsync(_mapper.Map <Person>(personDto)); return(Created(string.Empty, newPerson)); }
public void Update(PersonDto model) { // var entity = config.MapTo<PersonEntity>(); var entity = _personRepository.GetById(model.PersonUUID); entity = model.ToEntity(entity); entity.IsBasicInfo = true; //保存图片 String Tpath = "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/"; var parentPath = HostingEnvironment.MapPath("~/Upload"); string FilePath = parentPath + "/" + Tpath + "/"; if (model.CertificateIIMG != null && model.CertificateIIMG.Length > 0) { try { if (!Directory.Exists(FilePath)) { Directory.CreateDirectory(FilePath); } Image img = ImgUtil.BytToImg(model.CertificateIIMG); string _ImageExtension = ImgUtil.GetImageExtension(img); string FileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "." + _ImageExtension; var imgFullPath = Path.Combine(FilePath, FileName); img.Save(imgFullPath); entity.CertificateIPic = "Upload/" + Tpath + "/" + FileName; } catch (Exception ex) { Log.Error(ex, "图片上传失败"); } } if (model.IDCardImg != null && model.IDCardImg.Length > 0) { try { if (!Directory.Exists(FilePath)) { Directory.CreateDirectory(FilePath); } Image img = ImgUtil.BytToImg(model.IDCardImg); string _ImageExtension = ImgUtil.GetImageExtension(img); string FileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "." + _ImageExtension; var imgFullPath = Path.Combine(FilePath, FileName); img.Save(imgFullPath); entity.IDCardPic = "Upload/" + Tpath + "/" + FileName; } catch (Exception ex) { Log.Error(ex, "保存图片失败"); } } if (model.FaceImg != null && model.FaceImg.Length > 0) { try { if (!Directory.Exists(FilePath)) { Directory.CreateDirectory(FilePath); } Image img = ImgUtil.BytToImg(model.FaceImg); string _ImageExtension = ImgUtil.GetImageExtension(img); string FileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "." + _ImageExtension; var imgFullPath = Path.Combine(FilePath, FileName); img.Save(imgFullPath); entity.FacePic = "Upload/" + Tpath + "/" + FileName; } catch (Exception ex) { Log.Error(ex, "保存图片失败"); } } entity.UpdateTime = DateTime.Now; entity.SyncStatus = false; _personRepository.Update(entity); Synchronization(entity); }
public async Task AddPersonAsync(PersonDto personDto) { _adressbuchDbContext.Personen.Add(CopyDtoToDbModel(personDto)); await _adressbuchDbContext.SaveChangesAsync(); }
public async Task <IActionResult> Post([FromBody] PersonDto dto) { var result = await personApplication.Insert(dto); return(result.ValidationResult.IsValid ? Ok(result) : (IActionResult)BadRequest(result)); }
private PersonRequest CreatePerson(PersonRequest personRequest) { try { var result = FindPersonByIdentity(personRequest); if (result.WFMReturnCode == 0) { personRequest.ReturnType = ReturnTypes.ReturnTypeEnum.DataError; personRequest.WFMReturnCode = -101; personRequest.WFMReturnMessage += String.Format(@"Уже есть сотрудник с таким Identity [{0}]! ", personRequest.Identity); return personRequest; } var result2 = FindPersonByEmploymentNumber(personRequest); if (result2.WFMReturnCode == 0) { personRequest.ReturnType = ReturnTypes.ReturnTypeEnum.DataError; personRequest.WFMReturnCode = -102; personRequest.WFMReturnMessage += String.Format(@"Уже есть сотрудник с таким EmploymentNumber [{0}]! ", personRequest.EmploymentNumber); return personRequest; } var result3 = FindPersonByApplicationLogonName(personRequest); if (result3.WFMReturnCode == 0) { personRequest.ReturnType = ReturnTypes.ReturnTypeEnum.DataError; personRequest.WFMReturnCode = -103; personRequest.WFMReturnMessage += String.Format(@"Уже есть сотрудник с таким ApplicationLogonName [{0}]! ", personRequest.ApplicationLogOnName); return personRequest; } PersonDto personDto = new PersonDto(); personDto.ApplicationLogOnName = personRequest.ApplicationLogOnName; personDto.ApplicationLogOnPassword = personRequest.ApplicationLogOnPassword; int cultureLanguageId = 0; int.TryParse(personRequest.CultureLanguageId, out cultureLanguageId); personDto.CultureLanguageId = cultureLanguageId; personDto.CultureLanguageIdSpecified = true; personDto.Email = personRequest.Email; personDto.EmploymentNumber = personRequest.EmploymentNumber; int firstDayOfWeek = 0; int.TryParse(personRequest.FirstDayOfWeek, out firstDayOfWeek); personDto.FirstDayOfWeek = DayOfWeek.Monday; personDto.FirstDayOfWeekSpecified = true; personDto.FirstName = personRequest.FirstName; personDto.Identity = personRequest.Identity; personDto.IsDeleted = false; personDto.IsDeletedSpecified = true; personDto.LastName = personRequest.LastName; int uicultureLanguageId = 0; int.TryParse(personRequest.UICultureLanguageId, out uicultureLanguageId); personDto.UICultureLanguageId = uicultureLanguageId; personDto.Name = personRequest.Name; personDto.Note = personRequest.Note; personDto.TerminationDate = null; personDto.TimeZoneId = personRequest.TimeZoneId; personDto.WindowsDomain = personRequest.WindowsDomain; personDto.WindowsLogOnName = personRequest.WindowsLogOnName; wfmServiceApplication.OrganizationService.AddPerson(personDto); var findNewPerson = FindPersonByEmploymentNumber(personRequest); if (findNewPerson.WFMReturnCode == 0) { personRequest.WFMReturnCode = 0; personRequest.WFMReturnMessage += String.Format(@"Сотрудник ID [{0}] добавлен в Бизнес-Юнит [{1}]; ", findNewPerson.PersonID, BusinessUnit); var assignRes = AssignPerson(personRequest); personRequest.NewPersonID = findNewPerson.PersonID; personRequest.WFMReturnCode = assignRes.WFMReturnCode; personRequest.WFMReturnMessage = assignRes.WFMReturnMessage; personRequest.ReturnType = assignRes.ReturnType; } } catch (Exception ex) { personRequest.WFMReturnCode = -1; personRequest.WFMReturnMessage += ex.Message; personRequest.ReturnType = ReturnTypes.ReturnTypeEnum.UnknownError; } return personRequest; }
public async Task <IActionResult> Put(Guid id, [FromBody] PersonDto dto) { var result = await personApplication.Update(dto); return(result.ValidationResult.IsValid ? Ok(result) : (IActionResult)BadRequest(result)); }
private void DisplaySentLogin( Direction direction ) { using ( new Rock.Data.UnitOfWorkScope() ) { PersonService personService = new PersonService(); Person person = personService.Get( Int32.Parse( hfSendPersonId.Value ) ); if ( person != null ) { var mergeObjects = new Dictionary<string, object>(); mergeObjects.Add( "ConfirmAccountUrl", RootPath + "ConfirmAccount" ); var personDictionaries = new List<IDictionary<string, object>>(); var users = new List<IDictionary<string, object>>(); UserService userService = new UserService(); foreach ( UserLogin user in userService.GetByPersonId( person.Id ) ) { if ( user.ServiceType == AuthenticationServiceType.Internal ) { var userDictionary = new UserLoginDto( user ).ToDictionary(); userDictionary.Add( "ConfirmationCodeEncoded", user.ConfirmationCodeEncoded ); users.Add( userDictionary ); } } if ( users.Count > 0 ) { IDictionary<string, object> personDictionary = new PersonDto( person ).ToDictionary(); personDictionary.Add( "FirstName", person.FirstName ); personDictionary.Add( "Users", users.ToArray() ); personDictionaries.Add( personDictionary ); } mergeObjects.Add( "Persons", personDictionaries.ToArray() ); var recipients = new Dictionary<string, Dictionary<string, object>>(); recipients.Add( person.Email, mergeObjects ); Email email = new Email( Rock.SystemGuid.EmailTemplate.SECURITY_FORGOT_USERNAME ); email.Send( recipients ); } else ShowErrorMessage( "Invalid Person" ); } ShowPanel( 3 ); }
public FacultyDto(long _facultyId, string _office, double _salary, long _contactNo, PersonDto _person) { FacultyId = _facultyId; Office = _office; Salary = _salary; ContactNo = _contactNo; Person = _person; }
public int SaveList(PersonDto[] people) { var dataFilePath = Server.MapPath("~") + "People.json"; var json = JsonConvert.SerializeObject(people); return _personService.SaveList(people, dataFilePath); }
public async Task AddPersongAsync(PersonDto person) { person.PersonId = _persons.Max(p => p.PersonId) + 1; _persons.Add(person); }
protected override void Because_of() { _destination = Mapper.Map <PersonDto>(new Person { PrefixNamePostfix = "John" }); }
public bool UpdatePerson(PersonDto personInfo) { throw new NotImplementedException(); }
public PersonRequest Clone(PersonDto o) { PersonRequest clone = new PersonRequest(); clone.ApplicationLogOnName = o.ApplicationLogOnName; clone.ApplicationLogOnPassword = o.ApplicationLogOnPassword; clone.CultureLanguageId = o.CultureLanguageId.ToString(); clone.Email = o.Email; clone.EmploymentNumber = o.EmploymentNumber; clone.FirstDayOfWeek = o.FirstDayOfWeek.ToString(); clone.FirstName = o.FirstName; clone.Identity = o.Identity; clone.LastName = o.LastName; clone.Note = o.Note; clone.PersonID = o.Id; if (o.TerminationDate != null) { clone.TerminationDate = o.TerminationDate.DateTime; } else { clone.TerminationDate = new DateTime(); } clone.TimeZoneId = o.TimeZoneId; clone.UICultureLanguageId = o.UICultureLanguageId.ToString(); clone.WindowsDomain = o.WindowsDomain; clone.WindowsLogOnName = o.WindowsLogOnName; return clone; }
public EditPersonScheduleViewModel(PersonDto person) { this.Person = person; }