public int UpdatePersonOccupation(PersonOccupation pe) { using (UnitOfWork unitOfWork = new UnitOfWork(new RecordContext())) { unitOfWork.PersonOccupationRepository.Update(pe); result = unitOfWork.Complete(); unitOfWork.Dispose(); return(result); } }
public int UpdatePersonOccupation(int personId, int userId, int occupation) { PersonOccupation pm = new PersonOccupation() { PersonId = personId, Occupation = occupation, CreatedBy = userId }; _result = _mgr.UpdatePersonOccupation(pm); return(_result); }
public int AddPersonOccupation(int userId, int occupation, int personId) { PersonOccupation pm = new PersonOccupation() { PersonId = personId, CreatedBy = userId, Occupation = occupation }; _result = _mgr.AddPersonOccupation(pm); return(_result); }
public int UpdateOccupation(PersonOccupation pm) { try { _result = _mgr.UpdatePersonOccupation(pm); return(_result); } catch (Exception e) { _msg = e.Message + ' ' + e.InnerException; throw; } }
public async Task <Result <GetPersonDetailsResponse> > Handle(GetPersonDetailsCommand request, CancellationToken cancellationToken) { try { RegisterPersonService rs = new RegisterPersonService(_unitOfWork); int id = request.PersonId; if (request.PersonId > 0) { persondetail = await rs.GetPerson(id); personEducation = await rs.GetCurrentPersonEducation(id); personocc = await rs.GetCurrentOccupation(id); personmarital = await rs.GetFirstPatientMaritalStatus(id); personlocation = await rs.GetCurrentPersonLocation(id); personcontact = await rs.GetCurrentPersonContact(id); personemerg = await rs.GetCurrentPersonEmergency(id); pid = await rs.GetCurrentPersonIdentifier(id); pt = await rs.GetPatientByPersonId(id); } _unitOfWork.Dispose(); return(Result <GetPersonDetailsResponse> .Valid(new GetPersonDetailsResponse() { personDetail = persondetail, personEducation = personEducation, personOccupation = personocc, personMaritalStatus = personmarital, personLocation = personlocation, personContact = personcontact, PersonEmergencyView = personemerg, personIdentifier = pid, patient = pt })); } catch (Exception ex) { return(Result <GetPersonDetailsResponse> .Invalid(ex.Message)); } }
public async Task <PersonOccupation> Update(PersonOccupation personOccupation) { try { _commonUnitOfWork.Repository <PersonOccupation>().Update(personOccupation); await _commonUnitOfWork.SaveAsync(); return(personOccupation); } catch (Exception e) { Log.Error(e.Message + " " + e.InnerException); throw e; } }
public async Task <Result <AddPersonOccupationLevelResponse> > Handle(PersonOccupationLevelCommand request, CancellationToken cancellationToken) { PersonOccupation pmo = new PersonOccupation(); try { if (request.PersonId > 0) { PersonOccupationManager pm = new PersonOccupationManager(); pmo = pm.GetCurrentOccupationion(request.PersonId); if (pmo != null) { pmo.DeleteFlag = true; int result; result = pm.UpdateOccupation(pmo); res = await Task.Run(() => pm.AddPersonOccupation(request.PersonId, request.UserId, request.Occupation)); if (res > 0) { msg = "PersonOccupation Updated successfully"; } } else { res = await Task.Run(() => pm.AddPersonOccupation(request.UserId, request.Occupation, request.PersonId)); if (res > 0) { msg = "PersonOccupation added successfully for personId" + request.PersonId; } } } return(Result <AddPersonOccupationLevelResponse> .Valid(new AddPersonOccupationLevelResponse() { Message = msg } )); } catch (Exception e) { return(Result <AddPersonOccupationLevelResponse> .Invalid(e.Message)); } }
public async Task <Result <AddPersonOccupationLevelResponse> > Handle(PersonOccupationLevelCommand request, CancellationToken cancellationToken) { try { RegisterPersonService sc = new RegisterPersonService(_unitOfWork); if (request.PersonId > 0) { PersonOccupation pmo = new PersonOccupation(); pmo = await Task.Run(() => sc.GetCurrentOccupation(request.PersonId)); if (pmo != null) { pmo.DeleteFlag = true; var pm = await Task.Run(() => sc.UpdateOccupation(pmo)); // var AddedPersonOcc = await Task.Run(() => sc.AddPersonOccupation(request.PersonId, request.UserId, request.Occupation)); if (pm != null) { msg = "PersonOccupation Updated successfully"; } } else { var AddedPersonOcc = await Task.Run(() => sc.AddPersonOccupation(request.PersonId, request.UserId, request.Occupation)); if (AddedPersonOcc != null) { msg = "PersonOccupation Added successfully for personId" + request.PersonId; } } } return(Result <AddPersonOccupationLevelResponse> .Valid(new AddPersonOccupationLevelResponse() { Message = msg })); } catch (Exception e) { return(Result <AddPersonOccupationLevelResponse> .Invalid(e.Message)); } }
public async Task <Result <AddPersonOccupationLevelResponse> > Handle(PersonOccupationLevelCommand request, CancellationToken cancellationToken) { try { PersonOccupationService personOccupationService = new PersonOccupationService(_unitOfWork); List <PersonOccupation> personOccupations = await personOccupationService.GetCurrentOccupation(request.PersonId); PersonOccupation personOccupation = new PersonOccupation(); if (personOccupations.Count > 0) { personOccupations[0].Occupation = request.Occupation; personOccupation = await personOccupationService.Update(personOccupations[0]); } else { PersonOccupation pc = new PersonOccupation() { PersonId = request.PersonId, Occupation = request.Occupation, CreateDate = DateTime.Now, CreatedBy = request.UserId, Active = false, DeleteFlag = false }; personOccupation = await personOccupationService.Add(pc); } return(Result <AddPersonOccupationLevelResponse> .Valid(new AddPersonOccupationLevelResponse() { Message = "Success", OccupationId = personOccupation.Id })); } catch (Exception e) { return(Result <AddPersonOccupationLevelResponse> .Invalid(e.Message)); } }
public async Task <PersonOccupation> Update(int personId, string occupation, int userid) { try { List <PersonOccupation> personOccupations = await this.GetCurrentOccupation(personId); PersonOccupation personOccupation = new PersonOccupation(); if (personOccupations.Count > 0) { personOccupations[0].Occupation = Convert.ToInt32(occupation); personOccupation = await this.Update(personOccupations[0]); } else { PersonOccupation pc = new PersonOccupation() { PersonId = personId, Occupation = Convert.ToInt32(occupation), CreateDate = DateTime.Now, CreatedBy = userid, Active = false, DeleteFlag = false }; personOccupation = await this.Add(pc); } return(personOccupation); } catch (Exception e) { Log.Error(e.Message + " " + e.InnerException); throw e; } }