public async Task <List <SearchedOrgPositionModel> > Handle(SaveOrgPositionCommand request, CancellationToken cancellationToken) { List <SearchedOrgPositionModel> result = new List <SearchedOrgPositionModel>(); if (request.Id == null || request.Id == default(int)) { result = await _mediator.Send(new SearchOrgPosition_Query() { PositionTypeId = request.PositionTypeId, OrgUnitTypeId = request.OrgUnitTypeId }); if (result.Any()) { throw new BusinessRulesException("وظیفه انتخاب شده از قبل در سیستم موجود است"); } using (_context) { OrgPosition orgposition = new OrgPosition() { ParentId = request.ParentId, PositionTypeId = request.PositionTypeId, OrgUnitTypeId = request.OrgUnitTypeId, RankId = request.RankId, }; _context.OrgPosition.Add(orgposition); await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new SearchOrgPosition_Query() { Id = orgposition.Id }); } } else { using (_context) { OrgPosition toUpdateRecord = await _context.OrgPosition.Where(or => or.Id == request.Id).SingleOrDefaultAsync(); toUpdateRecord.ParentId = request.ParentId; toUpdateRecord.PositionTypeId = request.PositionTypeId; toUpdateRecord.OrgUnitTypeId = request.OrgUnitTypeId; toUpdateRecord.RankId = request.RankId; await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new SearchOrgPosition_Query() { Id = toUpdateRecord.Id }); } } return(result); }
public async Task <List <SearchedWorkAreaModel> > Handle(SaveWorkAreaCommand request, CancellationToken cancellationToken) { List <SearchedWorkAreaModel> result = new List <SearchedWorkAreaModel>(); if (request.Id == null || request.Id == default(int)) { result = await _mediator.Send(new SearchWorkAreaQuery() { Title = request.Title }); if (result.Any()) { throw new BusinessRulesException("ساحه کاری انتخاب شده از قبل در سیستم موجود است"); } using (_context) { WorkArea workarea = new WorkArea() { Title = request.Title, TitleEng = request.TitleEng }; _context.WorkArea.Add(workarea); await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new SearchWorkAreaQuery() { Id = workarea.Id }); } } else { using (_context) { WorkArea toUpdateRecord = await _context.WorkArea.Where(or => or.Id == request.Id).SingleOrDefaultAsync(); toUpdateRecord.Title = request.Title; toUpdateRecord.TitleEng = request.TitleEng; await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new SearchWorkAreaQuery() { Id = toUpdateRecord.Id }); } } return(result); }
public async Task <List <SearchedPlan> > Handle(ConfirmPlanCommand request, CancellationToken cancellationToken) { List <SearchedPlan> result = new List <SearchedPlan>(); if (request.Id != default(int)) { using (_context) { OrganoGram toUpdateRecord = await(from org in _context.OrganoGram where org.Id == request.Id select org).SingleOrDefaultAsync(); toUpdateRecord.StatusId = request.StatusId; await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new Queries.SearchPlanQuery() { Id = toUpdateRecord.Id }); } } return(result); }
public async Task <List <SearchedPosition> > Handle(DeletePositionCommand request, CancellationToken cancellationToken) { List <SearchedPosition> parentOfThePositionToBeDeleted = new List <SearchedPosition>(); List <Position> childs = await _context.Position.Where(p => p.ParentId == request.Id).ToListAsync(cancellationToken); if (childs.Any()) { throw new BusinessRulesException("بست انتخاب شده دارای بست های مادون میباشد، لطفاً بست های مادون را حذف نمائید، بعداً شما میتوانید که این بست را حذف نمائید"); } if (request.Id != default(decimal)) { Position toDeletePosition = await _context.Position.Where(p => p.Id == request.Id).FirstOrDefaultAsync(cancellationToken); if (toDeletePosition != null) { _context.Position.Remove(toDeletePosition); await _context.SaveChangesAsync(cancellationToken); parentOfThePositionToBeDeleted = await _mediator.Send(new SearchPositionQuery() { Id = toDeletePosition.ParentId }); } else { throw new BusinessRulesException("بست انتخاب شده در سیستم موجود نمیباشد"); } } return(parentOfThePositionToBeDeleted); }
public async Task <List <SearchedIdentityCardModel> > Handle(SetIdentityCardCommand request, CancellationToken cancellationToken) { int CurrentUserId = await _currentUser.GetUserId(); List <SearchedIdentityCardModel> listOfCards = new List <SearchedIdentityCardModel>(); // Check if person is employed if (_context.Selection.Where(s => s.PersonId == request.PersonId).Any()) { IdentityCard card = new IdentityCard() { CardCode = "CardCode", PersonId = request.PersonId, ValidUpto = request.ValidUpto, PhotoPath = request.PhotoPath, CardPrinted = false }; _context.IdentityCard.Add(card); await _context.SaveChangesAsync(cancellationToken); listOfCards = await _mediator.Send(new GetIdentityCardsQuery() { Id = card.Id }); } else { throw new BusinessRulesException("کارمند انتخاب شده تعیینات نشده است"); } return(listOfCards); }
public async Task <List <SearchedOrganizationModel> > Handle(SaveOrganiztionCommand request, CancellationToken cancellationToken) { List <SearchedOrganizationModel> result = new List <SearchedOrganizationModel>(); if (request.Id == default(decimal)) { List <Organization> List = _context.Organization.Where(o => o.Dari == request.Dari).ToList(); if (List.Any()) { throw new BusinessRulesException("ارگان انتخاب شده از قبل در سیستم وجود دارد"); } Organization organizations = new Organization() { Name = request.Name, Dari = request.Dari, Pashto = request.Pashto, OrgUnitTypeId = request.OrgUnitTypeId, Code = request.Code, StatusId = request.StatusId }; _context.Organization.Add(organizations); await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new SearchOrganizationQuery() { Id = organizations.Id }); } else { Organization UpdateRecord = await _context.Organization.Where(or => or.Id == request.Id).FirstOrDefaultAsync(cancellationToken); UpdateRecord.Name = request.Name; UpdateRecord.Dari = request.Dari; UpdateRecord.Pashto = request.Pashto; UpdateRecord.OrgUnitTypeId = request.OrgUnitTypeId; UpdateRecord.Code = request.Code; UpdateRecord.StatusId = request.StatusId; await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new SearchOrganizationQuery() { Id = UpdateRecord.Id }); } return(result); }
public async Task <IActionResult> Async([FromBody] List <DailyLog> data) { // Validate the request: return 400 if the request contains 0 no of records. if (data.Count >= 1) { using (var transaction = _context.Database.BeginTransaction()) { try { foreach (DailyLog log in data) { //Validate the request: rollback the transaction if a duplicate entry is found in the request. if (_context.DailyLog.Where(l => l.UserId == log.UserId && l.AttendanceDate == log.AttendanceDate).Any()) { throw new Exception(new StringBuilder() .Append($"Attendance record for the employee with id [{log.UserId}] in [{log.AttendanceDate}]") .Append(" already exists").ToString()); } else { _context.DailyLog.Add(log); } } await _context.SaveChangesAsync(); transaction.Commit(); return(Ok(new JsonResult(new UIResult() { Text = "Records were logged successfully" }))); } catch (Exception ex) { transaction.Rollback(); StringBuilder builder = new StringBuilder(); builder.Append("Transaction Error").Append("\n") .Append("Message") .Append("\n") .Append(ex.Message); return(StatusCode(500, new JsonResult(new UIResult() { Text = builder.ToString() }))); } } } else { return(StatusCode(400, new JsonResult(new UIResult() { Text = "Sent list is empty" }))); } }
public async Task <List <SearchedProcessTracks> > Handle(SaveProcessTracksCommand request, CancellationToken cancellationToken) { List <SearchedProcessTracks> result = new List <SearchedProcessTracks>(); if (request.Id == null) { ProcessTracking PT = new ProcessTracking() { RecordId = request.RecordId, ProcessId = (Int16)request.ProcessId, StatusId = 5, // In Process ModuleId = request.ModuleId, ReferedProcessId = 1, CreatedOn = DateTime.Now }; _context.ProcessTracking.Add(PT); await _context.SaveChangesAsync(cancellationToken); } else { ProcessTracking track = await(from a in _context.ProcessTracking where a.Id == request.Id select a).SingleOrDefaultAsync(); track.StatusId = 6; track.ReferedProcessId = request.ReferedProcessId; ProcessTracking PT = new ProcessTracking() { RecordId = request.RecordId, ProcessId = (Int16)request.ReferedProcessId, StatusId = 5, Remarks = request.Remarks, ModuleId = request.ModuleId, CreatedOn = DateTime.Now }; _context.ProcessTracking.Add(PT); await _context.SaveChangesAsync(cancellationToken); } result = await _mediator.Send(new SearchProcessTrackQuery() { RecordId = request.RecordId, ModuleId = request.ModuleId }); return(result); }
public async Task <string> Handle(DeletePersonTravelCommand request, CancellationToken cancellationToken) { using (_context) { Travel toDeleteRelative = new Travel(); toDeleteRelative = await(from t in _context.Travel where t.Id == request.ID select t).FirstOrDefaultAsync(); if (toDeleteRelative != null) { _context.Travel.Remove(toDeleteRelative); await _context.SaveChangesAsync(cancellationToken); } } return(string.Empty); }
public async Task <string> Handle(DeletePersonAssetCommand request, CancellationToken cancellationToken) { using (_context) { PersonAsset toDeletePersonAsset = new PersonAsset(); toDeletePersonAsset = await(from a in _context.PersonAsset where a.Id == request.Id select a).FirstOrDefaultAsync(); if (toDeletePersonAsset != null) { _context.PersonAsset.Remove(toDeletePersonAsset); await _context.SaveChangesAsync(cancellationToken); } } return(string.Empty); }
public async Task <string> Handle(DeletePersonRelativesCommand request, CancellationToken cancellationToken) { using (_context) { Relative toDeleteRelative = new Relative(); toDeleteRelative = (from r in _context.Relative where r.Id == request.ID select r).FirstOrDefault(); if (toDeleteRelative != null) { _context.Relative.Remove(toDeleteRelative); await _context.SaveChangesAsync(cancellationToken); } } return(string.Empty); }
public async Task <string> Handle(DeletePersonEducationCommand request, CancellationToken cancellationToken) { using (_context) { Education toDeleteEducation = new Education(); toDeleteEducation = await(from ed in _context.Education where ed.Id == request.ID select ed).FirstOrDefaultAsync(); if (toDeleteEducation != null) { _context.Education.Remove(toDeleteEducation); await _context.SaveChangesAsync(cancellationToken); } } return(string.Empty); }
public async Task <string> Handle(DeletePersonAddressCommand request, CancellationToken cancellationToken) { using (_context) { Address toDeleteAddress = new Address(); toDeleteAddress = await(from ed in _context.Address where ed.Id == request.ID select ed).FirstOrDefaultAsync(); if (toDeleteAddress != null) { _context.Address.Remove(toDeleteAddress); await _context.SaveChangesAsync(cancellationToken); } } return(string.Empty); }
public async Task<string> Handle(DeletePersonLanguageCommand request, CancellationToken cancellationToken) { using (_context) { PersonLanguage toDeletePersonLanguage = new PersonLanguage(); toDeletePersonLanguage = await (from pl in _context.PersonLanguage where pl.Id == request.ID select pl).FirstOrDefaultAsync(); if (toDeletePersonLanguage != null) { _context.PersonLanguage.Remove(toDeletePersonLanguage); await _context.SaveChangesAsync(cancellationToken); } } return string.Empty; }
public async Task <string> Handle(DeletePersonMilitaryServiceCommand request, CancellationToken cancellationToken) { if (request.ID != null) { using (_context) { MilitaryService toDeleteMilitaryService = new MilitaryService(); toDeleteMilitaryService = await(from ex in _context.MilitaryService where ex.Id == request.ID select ex).FirstOrDefaultAsync(); if (toDeleteMilitaryService != null) { _context.MilitaryService.Remove(toDeleteMilitaryService); await _context.SaveChangesAsync(cancellationToken); } } return(string.Empty); } return(string.Empty); }
public async Task <List <SearchedPersonSkill> > Handle(SavePersonSkillsCommand request, CancellationToken cancellationToken) { List <SearchedPersonSkill> result = new List <SearchedPersonSkill>(); if (request.Id == null || request.Id == default(decimal)) { using (_context) { PersonSkill personSkill = new PersonSkill() { PersonId = request.PersonId, LanguageId = request.LanguageId, ExpertiseId = request.ExpertiseId, ModifiedOn = request.ModifiedOn, ModifiedBy = request.ModifiedBy, ReferenceNo = request.ReferenceNo, CreatedOn = request.CreatedOn, CreatedBy = request.CreatedBy, Locationid = request.Locationid, Remarks = request.Remarks, CertificationId = request.CertificationId, CertifiedFrom = request.CertifiedFrom, CertificationDate = request.CertificationDate, StartDate = request.StartDate, EndDate = request.EndDate }; _context.PersonSkill.Add(personSkill); await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new Queries.SearchPersonSkillQuery() { Id = personSkill.Id }); } } else { using (_context) { PersonSkill toUpdateRecord = await(from ps in _context.PersonSkill where ps.Id == request.Id select ps).SingleOrDefaultAsync(); toUpdateRecord.PersonId = request.PersonId; toUpdateRecord.LanguageId = request.LanguageId; toUpdateRecord.ExpertiseId = request.ExpertiseId; toUpdateRecord.ModifiedOn = request.ModifiedOn; toUpdateRecord.ModifiedBy = request.ModifiedBy; toUpdateRecord.ReferenceNo = request.ReferenceNo; toUpdateRecord.CreatedOn = request.CreatedOn; toUpdateRecord.CreatedBy = request.CreatedBy; toUpdateRecord.Locationid = request.Locationid; toUpdateRecord.Remarks = request.Remarks; toUpdateRecord.CertificationId = request.CertificationId; toUpdateRecord.CertifiedFrom = request.CertifiedFrom; toUpdateRecord.CertificationDate = request.CertificationDate; toUpdateRecord.StartDate = request.StartDate; toUpdateRecord.EndDate = request.EndDate; await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new Queries.SearchPersonSkillQuery() { Id = toUpdateRecord.Id }); } } return(result); }
public async Task <List <SearchedPersonExperience> > Handle(SavePersonExperienceCommand request, CancellationToken cancellationToken) { List <SearchedPersonExperience> result = new List <SearchedPersonExperience>(); if (request.Id == null || request.Id == default(decimal)) { // Save int CurrentUserId = await _currentUser.GetUserId(); using (var transaction = _context.Database.BeginTransaction()) { try { using (_context) { Experience personExperience = new Experience() { Designation = request.Designation, PersonId = request.PersonId, Organization = request.Organization, ModifiedOn = request.ModifiedOn, ModifiedBy = request.ModifiedBy, ReferenceNo = request.ReferenceNo, CreatedOn = request.CreatedOn, CreatedBy = request.CreatedBy ?? 10, // UNTILL : application of idenity RequestNo = request.RequestNo, LocationId = request.LocationId, DocumentNo = request.DocumentNo, RankId = request.RankId, PromotionId = request.PromotionId, StartDate = request.StartDate, EndDate = request.EndDate, ContactInfo = request.ContactInfo, JobstatusId = request.JobstatusId, JobDescription = request.JobDescription, Approved = request.Approved, Remarks = request.Remarks, ExperienceTypeId = request.ExperienceTypeId, }; _context.Experience.Add(personExperience); await _context.SaveChangesAsync(CurrentUserId, cancellationToken); result = await _mediator.Send(new SearchPersonExperienceQuery() { Id = personExperience.Id }); transaction.Commit(); } } catch (Exception ex) { transaction.Rollback(); throw new Exception(); } } } else { // Update Experience toUpdateExperience = await _context.Experience.Where(ex => ex.Id == request.Id).FirstOrDefaultAsync(cancellationToken); toUpdateExperience.PersonId = request.PersonId; toUpdateExperience.Organization = request.Organization; toUpdateExperience.ModifiedOn = request.ModifiedOn; toUpdateExperience.ModifiedBy = request.ModifiedBy; toUpdateExperience.ReferenceNo = request.ReferenceNo; toUpdateExperience.CreatedOn = request.CreatedOn; toUpdateExperience.CreatedBy = request.CreatedBy ?? 10; // UNTILL : untill application of Identity toUpdateExperience.RequestNo = request.RequestNo; toUpdateExperience.LocationId = request.LocationId; toUpdateExperience.DocumentNo = request.DocumentNo; toUpdateExperience.RankId = request.RankId; toUpdateExperience.PromotionId = request.PromotionId; toUpdateExperience.StartDate = request.StartDate; toUpdateExperience.EndDate = request.EndDate; toUpdateExperience.ContactInfo = request.ContactInfo; toUpdateExperience.JobstatusId = request.JobstatusId; toUpdateExperience.JobDescription = request.JobDescription; toUpdateExperience.Approved = request.Approved; toUpdateExperience.Remarks = request.Remarks; toUpdateExperience.ExperienceTypeId = request.ExperienceTypeId; await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new SearchPersonExperienceQuery() { Id = toUpdateExperience.Id }); } return(result); }
public async Task <List <SearchedPersonMilitaryService> > Handle(SavePersonMilitaryServiceCommand request, CancellationToken cancellationToken) { List <SearchedPersonMilitaryService> result = new List <SearchedPersonMilitaryService>(); if (request.Id == null || request.Id == default(int)) { // Save int CurrentUserId = await _currentUser.GetUserId(); using (var transaction = _context.Database.BeginTransaction()) { try { using (_context) { MilitaryService militaryService = new MilitaryService() { PersonId = request.PersonId, MilitaryServiceTypeId = request.MilitaryServiceTypeId, StartDate = request.StartDate, EndDate = request.EndDate, CreatedBy = request.CreatedBy, CreatedOn = request.CreatedOn, ModifiedBy = request.ModifiedBy, ModifiedOn = request.ModifiedOn, Remark = request.Remark }; _context.MilitaryService.Add(militaryService); await _context.SaveChangesAsync(CurrentUserId, cancellationToken); result = await _mediator.Send(new SearchPersonMilitaryServiceQuery() { Id = militaryService.Id }); transaction.Commit(); } } catch (Exception ex) { transaction.Rollback(); throw new Exception(); } } } else { using (_context) { MilitaryService toUpdateMilitaryService = await _context.MilitaryService.Where(ms => ms.Id == request.Id).SingleOrDefaultAsync(); toUpdateMilitaryService.PersonId = request.PersonId; toUpdateMilitaryService.MilitaryServiceTypeId = request.MilitaryServiceTypeId; toUpdateMilitaryService.StartDate = request.StartDate; toUpdateMilitaryService.EndDate = request.EndDate; toUpdateMilitaryService.CreatedBy = request.CreatedBy; toUpdateMilitaryService.CreatedOn = request.CreatedOn; toUpdateMilitaryService.ModifiedBy = request.ModifiedBy; toUpdateMilitaryService.ModifiedOn = request.ModifiedOn; toUpdateMilitaryService.Remark = request.Remark; await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new SearchPersonMilitaryServiceQuery() { Id = toUpdateMilitaryService.Id }); } } return(result); }
public async Task <List <SearchedPersonModel> > Handle(CreatePersonCommand request, CancellationToken cancellationToken) { List <SearchedPersonModel> result = new List <SearchedPersonModel>(); // Save if (request.Id == null || request.Id == default(decimal)) { int CurrentUserId = await _currentUser.GetUserId(); using (var transaction = _context.Database.BeginTransaction()) { try { #region BuildHrCode StringBuilder PrefixBuilder = new StringBuilder(string.Empty); StringBuilder HrCodeBuilder = new StringBuilder(string.Empty); // Build Prefix PrefixBuilder.Append(("00" + request.BirthLocationId.ToString()).Right(2)); PrefixBuilder.Append(("00" + Convert.ToDateTime(request.DateOfBirth).Month.ToString()).Right(2)); PrefixBuilder.Append(("0000" + Convert.ToDateTime(request.DateOfBirth).Year.ToString()).Right(4)); PrefixBuilder.Append(("00" + Convert.ToDateTime(request.CreatedOn).Day.ToString()).Right(2)); PrefixBuilder.Append(("00" + Convert.ToDateTime(request.CreatedOn).Month.ToString()).Right(2)); PrefixBuilder.Append(Convert.ToDateTime(request.CreatedOn).Year.ToString().Right(2)); //Build Suffix //Get Current Suffix where its prefix is equal to PrefixBuilder. int?Suffix; int?CurrentSuffix = await _context.Person.Where(p => p.PreFix == PrefixBuilder.ToString()).MaxAsync(s => s.Suffix); if (CurrentSuffix is null) { CurrentSuffix = 1; } Suffix = CurrentSuffix + 1; // Build HR Code HrCodeBuilder.Append(PrefixBuilder.ToString()); HrCodeBuilder.Append(("000" + Suffix.ToString()).Right(3)); #endregion BuildHrCode #region SaveAndReturnResult // Construct Person Object Person person = new Person() { FirstName = request.FirstName.Trim(), FirstNameEng = request.FirstNameEng.Trim(), LastName = request.LastName.Trim(), FatherName = request.FatherName, FatherNameEng = request.FatherNameEng, GrandFatherName = request.GrandFatherName, GrandFatherNameEng = request.GrandFatherNameEng, LastNameEng = request.LastNameEng.Trim(), PreFix = PrefixBuilder.ToString(), Suffix = Suffix, Hrcode = HrCodeBuilder.ToString(), DateOfBirth = request.DateOfBirth, BirthLocationId = request.BirthLocationId, GenderId = request.GenderId, MaritalStatusId = request.MaritalStatusId, EthnicityId = request.EthnicityId, ReligionId = request.ReligionId, Comments = request.Comments, StatusId = request.StatusId, Remark = request.Remark, BloodGroupId = request.BloodGroupId, ModifiedBy = request.ModifiedBy, CreatedBy = request.CreatedBy, CreatedOn = request.CreatedOn, Nid = request.Nid, PhotoPath = request.PhotoPath, DocumentTypeId = request.DocumentTypeId, OrganizationId = request.OrganizationId }; _context.Person.Add(person); await _context.SaveChangesAsync(CurrentUserId, cancellationToken); ProcessTracking PT = new ProcessTracking() { // CHANGE: Don't convert person.Id to integer, instead make the RecordId to include different types RecordId = Convert.ToInt32(person.Id), ProcessId = (Int16)request.ProcessID, StatusId = 5, // In Process ModuleId = request.ModuleID, ReferedProcessId = 1, CreatedOn = DateTime.Now }; _context.ProcessTracking.Add(PT); await _context.SaveChangesAsync(CurrentUserId, cancellationToken); result = await _personCommon.SearchPerson(new SearchPersonQuery() { Id = person.Id }); #endregion SaveAndReturnResult transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw new Exception(); } } return(result); } // Update else { Person UpdateablePerson = (from p in _context.Person where p.Id == request.Id select p).First(); UpdateablePerson.FirstName = request.FirstName; UpdateablePerson.LastName = request.LastName; UpdateablePerson.FatherName = request.FatherName; UpdateablePerson.FatherNameEng = request.FatherNameEng; UpdateablePerson.GrandFatherName = request.GrandFatherName; UpdateablePerson.FirstNameEng = request.FirstNameEng; UpdateablePerson.LastNameEng = request.LastNameEng; UpdateablePerson.GrandFatherNameEng = request.GrandFatherNameEng; UpdateablePerson.BirthLocationId = request.BirthLocationId; UpdateablePerson.GenderId = request.GenderId; UpdateablePerson.MaritalStatusId = request.MaritalStatusId; UpdateablePerson.EthnicityId = request.EthnicityId; UpdateablePerson.ReligionId = request.ReligionId; UpdateablePerson.Comments = request.Comments; UpdateablePerson.BloodGroupId = request.BloodGroupId; UpdateablePerson.Nid = request.Nid; UpdateablePerson.PhotoPath = request.PhotoPath; UpdateablePerson.DocumentTypeId = request.DocumentTypeId; UpdateablePerson.OrganizationId = request.OrganizationId; await _context.SaveChangesAsync(); result = await _personCommon.SearchPerson(new SearchPersonQuery() { Id = UpdateablePerson.Id }); return(result); } }
public async Task <List <SearchedPersonRelative> > Handle(SavePersonRelatives request, CancellationToken cancellationToken) { List <SearchedPersonRelative> result = new List <SearchedPersonRelative>(); if (request.Id == null || request.Id == default(decimal)) { int CurrentUserId = await _currentUser.GetUserId(); using (var transaction = _context.Database.BeginTransaction()) { try { using (_context) { Relative relative = new Relative() { RelationShipId = request.RelationShipId, FirstName = request.FirstName, LastName = request.LastName, FatherName = request.FatherName, GrandFatherName = request.GrandFatherName, Profession = request.Profession, LocationId = request.LocationId, PersonId = request.PersonId, NidNo = request.NidNo, Address = request.Address, ContactInfo = request.ContactInfo, EmailAddress = request.EmailAddress, Village = request.Village, Remark = request.Remark, CreatedOn = request.CreatedOn, ModifiedBy = request.ModifiedBy, ModifiedOn = request.ModifiedOn, CreatedBy = request.CreatedBy }; _context.Relative.Add(relative); await _context.SaveChangesAsync(CurrentUserId, cancellationToken); PersonCommon common = new PersonCommon(_context); // Return Saved Relative result = await common.SearchPersonRelative(new Queries.SearchPersonRelativeQuery() { Id = relative.Id }, cancellationToken); } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw new Exception(); } } } else { using (_context) { Relative UpdateableRecord = await(from r in _context.Relative where r.Id == request.Id select r).FirstOrDefaultAsync(cancellationToken); UpdateableRecord.FatherName = request.FatherName; UpdateableRecord.FirstName = request.FirstName; UpdateableRecord.LastName = request.LastName; UpdateableRecord.PersonId = request.PersonId; UpdateableRecord.GrandFatherName = request.GrandFatherName; UpdateableRecord.RelationShipId = request.RelationShipId; UpdateableRecord.NidNo = request.NidNo; UpdateableRecord.Profession = request.Profession; UpdateableRecord.Address = request.Address; UpdateableRecord.ContactInfo = request.ContactInfo; UpdateableRecord.EmailAddress = request.EmailAddress; UpdateableRecord.Village = request.Village; UpdateableRecord.Remark = request.Remark; UpdateableRecord.ModifiedBy = request.ModifiedBy; UpdateableRecord.ModifiedOn = request.ModifiedOn; await _context.SaveChangesAsync(cancellationToken); PersonCommon common = new PersonCommon(_context); // Return Saved Relative result = await common.SearchPersonRelative(new Queries.SearchPersonRelativeQuery() { Id = UpdateableRecord.Id }, cancellationToken); } } return(result); }
public async Task <List <SearchedPersonTravel> > Handle(SavePersonTravelCommand request, CancellationToken cancellationToken) { List <SearchedPersonTravel> result = new List <SearchedPersonTravel>(); if (request.Id == null || request.Id == default(decimal)) { using (_context) { Travel PersonTravel = new Travel() { PersonId = request.PersonId, CountryId = request.CountryId, Place = request.Place, TravelDate = request.TravelDate, ReturnDate = request.ReturnDate, Reason = request.Reason, AccompanyWith = request.AccompanyWith, ReferenceNo = request.ReferenceNo, CreatedOn = request.CreatedOn, CreatedBy = request.CreatedBy }; _context.Travel.Add(PersonTravel); await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new Queries.SearchPersonTravelQuery() { Id = PersonTravel.Id }); } } else { using (_context) { Travel toUpdateRecord = await(from pt in _context.Travel where pt.Id == request.Id select pt).SingleOrDefaultAsync(); toUpdateRecord.PersonId = request.PersonId; toUpdateRecord.CountryId = request.CountryId; toUpdateRecord.Place = request.Place; toUpdateRecord.TravelDate = request.TravelDate; toUpdateRecord.ReturnDate = request.ReturnDate; toUpdateRecord.Reason = request.Reason; toUpdateRecord.AccompanyWith = request.AccompanyWith; toUpdateRecord.ReferenceNo = request.ReferenceNo; toUpdateRecord.CreatedOn = request.CreatedOn; toUpdateRecord.CreatedBy = request.CreatedBy; await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new Queries.SearchPersonTravelQuery() { Id = toUpdateRecord.Id }); } } return(result); }
public async Task <List <SearchedSelectionModel> > Handle(CreateSelectionCommand request, CancellationToken cancellationToken) { List <SearchedSelectionModel> result = new List <SearchedSelectionModel>(); if (request.Id == null || request.Id == default(decimal)) { // Business Rule Check 1 : Check if person has already been selected for any position at the selected Tashkil Selection SS = (from S in _context.Selection join P in _context.Position on S.PositionId equals P.Id into SP from spResult in SP.DefaultIfEmpty() join org in _context.OrganoGram on spResult.OrganoGramId equals org.Id into spOrg from spOrgResult in spOrg.DefaultIfEmpty() where spOrgResult.Id == request.OrganoGramID && S.PersonId == request.PersonId select S ).SingleOrDefault(); //if ((from S in _context.Selection // join P in _context.Position on S.PositionId equals P.Id into SP // from spResult in SP.DefaultIfEmpty() // join org in _context.OrganoGram on spResult.OrganoGramId equals org.Id into spOrg // from spOrgResult in spOrg.DefaultIfEmpty() // where spOrgResult.Id == request.OrganoGramID && S.PersonId == request.PersonId // select S).Any()) if (SS != null) { throw new BusinessRulesException("شخص انتخاب شده در تشکیل فعلی قبلا شاغل یکی از بست ها میباشد"); } else { Selection selection = new Selection() { PositionId = request.PositionId, PersonId = request.PersonId, EffectiveDate = request.EffectiveDate, VerdictDate = request.VerdictDate, EventTypeId = request.EventTypeId, VerdictRegNo = request.VerdictRegNo, Remarks = request.Remarks, FinalNo = request.FinalNo, QadamID = request.QadamID, DepartmentID = request.DepartmentID }; _context.Selection.Add(selection); await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new SearchSelectionQuery() { PositionId = Convert.ToInt16(selection.PositionId) }); return(result); } } else { Selection d = (from p in _context.Selection where p.Id == request.Id select p).First(); d.PositionId = request.PositionId; d.PersonId = request.PersonId; d.EventTypeId = request.EventTypeId; d.EffectiveDate = request.EffectiveDate; d.VerdictDate = request.VerdictDate; d.VerdictRegNo = request.VerdictRegNo; d.Remarks = request.Remarks; d.FinalNo = request.FinalNo; d.QadamID = request.QadamID; d.DepartmentID = request.DepartmentID; await _context.SaveChangesAsync(); result = await _mediator.Send(new SearchSelectionQuery() { OrganoGramId = _context.Position.Where(a => a.Id == request.PositionId).SingleOrDefault().OrganoGramId }); return(result); } }
public async Task <List <SearchedDocumentModel> > Handle(CreateDocumentCommand request, CancellationToken cancellationToken) { List <SearchedDocumentModel> result = new List <SearchedDocumentModel>(); // Save if (request.Id == null || request.Id == default(decimal)) { using (_context) { Documents d = new Documents() { ContentType = request.ContentType, UploadDate = DateTime.Now, // Module = request.Module, // Item = request.Item, RecordId = request.RecordId, Root = request.Root, Path = request.Path, ModifiedOn = DateTime.Now, ModifiedBy = "", CreatedOn = DateTime.Now, CreatedBy = 1, EncryptionKey = "", ReferenceNo = "", StatusId = 1, Description = request.Description, // DocumentTypeId = request.DocumentTypeId, LastDownloadDate = DateTime.Now }; _context.Document.Add(d); await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new SearchDocumentQuery() { Id = d.Id }); return(result); } } // Update else { using (_context) { Documents d = (from p in _context.Document where p.Id == request.Id select p).First(); d.ContentType = request.ContentType; d.Path = request.Path; d.ModifiedOn = DateTime.Now; d.ModifiedBy = "1"; d.EncryptionKey = ""; d.StatusId = 1; d.Description = request.Description; // d.DocumentTypeId = request.DocumentTypeId; d.LastDownloadDate = DateTime.Now; await _context.SaveChangesAsync(); result = await _mediator.Send(new SearchDocumentQuery() { Id = d.Id }); return(result); } } }
public async Task <List <SearchedPlan> > Handle(SavePlanCommand request, CancellationToken cancellationToken) { List <SearchedPlan> result = new List <SearchedPlan>(); if (request.Id == default(decimal)) { int CurrentUserId = await _currentUser.GetUserId(); using (var transaction = _context.Database.BeginTransaction()) { try { List <OrganoGram> List = _context.OrganoGram.Where(o => o.OrganizationId == request.OrganizationId && o.Year == request.Year).ToList(); if (List.Any()) { throw new BusinessRulesException("اداره در سال انتخاب شده تشکیل دارد"); } else { OrganoGram organogram = new OrganoGram() { OrganizationId = request.OrganizationId, IsPositionsCopied = request.IsPositionsCopied, StatusId = request.StatusId, Year = request.Year, NumberOfPositions = request.NumberOfPositions }; _context.OrganoGram.Add(organogram); await _context.SaveChangesAsync(CurrentUserId, cancellationToken); if (request.IsPositionsCopied == 1) { OrganoGram orglast = (from a in _context.OrganoGram where a.Year == (request.Year - 1) && a.OrganizationId == request.OrganizationId select a).SingleOrDefault(); List <Position> list = _context.Position.Where(c => c.OrganoGramId == orglast.Id && c.ParentId == null).ToList(); if (list.Any()) { await CopyPositionsAsync(list.FirstOrDefault(), organogram.Id, null); } } else { List <Organization> org = await _mediator.Send(new GetOrganiztionQuery() { Id = organogram.OrganizationId }); List <SearchedOrgPosition> orgp = await _mediator.Send(new SearchOrgPositionQuery() { Id = org.FirstOrDefault().OrgUnitTypeId, Children = false }); List <WorkArea> walist = (from a in _context.WorkArea where a.Title.Trim().Equals(org.FirstOrDefault().Dari.Trim()) select a).ToList(); if (!walist.Any()) { WorkArea a = new WorkArea(); a.Title = org.FirstOrDefault().Dari.Trim(); await _context.SaveChangesAsync(CurrentUserId, cancellationToken); walist = (from b in _context.WorkArea where b.Title.Trim().Equals(org.FirstOrDefault().Dari.Trim()) select b).ToList(); } List <SearchedPosition> positionresults = await _mediator.Send(new SavePositionCommand() { WorkingAreaId = Convert.ToInt32(walist.FirstOrDefault().Id), PositionTypeId = orgp.FirstOrDefault().Id, LocationId = 1, SalaryTypeId = 1, OrganoGramId = organogram.Id, Code = org.FirstOrDefault().Id.ToString() + "0000" + 1.ToString(), PlanTypeId = 1 }); } result = await _mediator.Send(new Queries.SearchPlanQuery() { Id = organogram.Id }); } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw new Exception(); } } } else { OrganoGram toUpdateRecord = await(from org in _context.OrganoGram where org.Id == request.Id select org).SingleOrDefaultAsync(); toUpdateRecord.OrganizationId = request.OrganizationId; toUpdateRecord.StatusId = request.StatusId; toUpdateRecord.Year = request.Year; toUpdateRecord.NumberOfPositions = request.NumberOfPositions; await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new Queries.SearchPlanQuery() { Id = toUpdateRecord.Id }); } return(result); }
public async Task <List <SearchedPersonLanguage> > Handle(SavePersonLanguageCommand request, CancellationToken cancellationToken) { List <SearchedPersonLanguage> result = new List <SearchedPersonLanguage>(); PersonCommon common = new PersonCommon(_context); if (request.Id == null || request.Id == default(decimal)) { int CurrentUserId = await _currentUser.GetUserId(); using (var transaction = _context.Database.BeginTransaction()) { try { using (_context) { PersonLanguage personLanguage = new PersonLanguage() { PersonId = request.PersonId, LanguageId = request.LanguageId, ReadingExpertise = request.ReadingExpertise, UnderstandingExpertise = request.UnderstandingExpertise, WritingExpertise = request.WritingExpertise, SpeakingExpertise = request.SpeakingExpertise, ReferenceNo = request.ReferenceNo, CreatedOn = request.CreatedOn, CreatedBy = request.CreatedBy }; _context.PersonLanguage.Add(personLanguage); await _context.SaveChangesAsync(CurrentUserId, cancellationToken); result = await common.SearchPersonLanguages(new Queries.SearchPersonLanguageQuery() { Id = personLanguage.Id }, cancellationToken); transaction.Commit(); } } catch (Exception ex) { transaction.Rollback(); throw new Exception(); } } } else { using (_context) { PersonLanguage toUpdateRecord = await(from pl in _context.PersonLanguage where pl.Id == request.Id select pl).SingleOrDefaultAsync(); toUpdateRecord.LanguageId = request.LanguageId; toUpdateRecord.ReadingExpertise = request.ReadingExpertise; toUpdateRecord.UnderstandingExpertise = request.UnderstandingExpertise; toUpdateRecord.WritingExpertise = request.WritingExpertise; toUpdateRecord.SpeakingExpertise = request.SpeakingExpertise; await _context.SaveChangesAsync(cancellationToken); //result = await _context.PersonLanguage.Where(pl => pl.Id == toUpdateRecord.Id).ToListAsync(cancellationToken); result = await common.SearchPersonLanguages(new Queries.SearchPersonLanguageQuery() { Id = toUpdateRecord.Id }, cancellationToken); } } return(result); }
public async Task <List <SearchedPersonReference> > Handle(SavePersonReferenceCommand request, CancellationToken cancellationToken) { List <SearchedPersonReference> result = new List <SearchedPersonReference>(); if (request.Id == null || request.Id == default(decimal)) { int CurrentUserId = await _currentUser.GetUserId(); using (var transaction = _context.Database.BeginTransaction()) { try { using (_context) { Reference reference = new Reference() { PersonId = request.PersonId, ModifiedOn = request.ModifiedOn, ModifiedBy = request.ModifiedBy, ReferenceNo = request.ReferenceNo, CreatedOn = request.CreatedOn, CreatedBy = request.CreatedBy, FirstName = request.FirstName, LastName = request.LastName, FatherName = request.FatherName, GrandFatherName = request.GrandFatherName, Occupation = request.Occupation, Organization = request.Organization, TelephoneNo = request.TelephoneNo, District = request.District, LocationId = request.LocationId, RelationShip = request.RelationShip, ReferenceTypeId = request.ReferenceTypeId, Amount = request.Amount, BankId = request.BankId, ReceiptNumber = request.ReceiptNumber, DocumentNumber = request.DocumentNumber, DocumentDate = request.DocumentDate, Remark = request.Remark }; _context.Reference.Add(reference); await _context.SaveChangesAsync(CurrentUserId, cancellationToken); result = await _mediator.Send(new Queries.SearchPersonReferenceQuery() { Id = reference.Id }); transaction.Commit(); } } catch (Exception ex) { transaction.Rollback(); throw new Exception(); } } } else { using (_context) { Reference reference = await(from refe in _context.Reference where refe.Id == request.Id select refe).SingleOrDefaultAsync(); reference.PersonId = request.PersonId; reference.ModifiedOn = request.ModifiedOn; reference.ModifiedBy = request.ModifiedBy; reference.ReferenceNo = request.ReferenceNo; reference.CreatedOn = request.CreatedOn; reference.CreatedBy = request.CreatedBy; reference.FirstName = request.FirstName; reference.LastName = request.LastName; reference.FatherName = request.FatherName; reference.GrandFatherName = request.GrandFatherName; reference.Occupation = request.Occupation; reference.Organization = request.Organization; reference.TelephoneNo = request.TelephoneNo; reference.District = request.District; reference.LocationId = request.LocationId; reference.RelationShip = request.RelationShip; reference.ReferenceTypeId = request.ReferenceTypeId; reference.Remark = request.Remark; reference.Amount = request.Amount; reference.BankId = request.BankId; reference.ReceiptNumber = request.ReceiptNumber; reference.DocumentNumber = request.DocumentNumber; reference.DocumentDate = request.DocumentDate; reference.Remark = request.Remark; await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new Queries.SearchPersonReferenceQuery() { Id = reference.Id }); } } return(result); }
public async Task <List <SearchedPersonAsset> > Handle(SavePersonAssetCommand request, CancellationToken cancellationToken) { List <SearchedPersonAsset> result = new List <SearchedPersonAsset>(); if (request.Id == null || request.Id == default(decimal)) { int CurrentUserId = await _currentUser.GetUserId(); using (var transaction = _context.Database.BeginTransaction()) { try { using (_context) { PersonAsset personAsset = new PersonAsset() { PersonId = request.PersonId, AssetTypeId = request.AssetTypeId, ModifiedOn = request.ModifiedOn, ModifiedBy = request.ModifiedBy, ReferenceNo = request.ReferenceNo, CreatedOn = request.CreatedOn, CreatedBy = request.CreatedBy, Description = request.Description, Value = request.Value }; _context.PersonAsset.Add(personAsset); await _context.SaveChangesAsync(CurrentUserId, cancellationToken); result = await _mediator.Send(new Queries.SearchPersonAssetQuery() { Id = personAsset.Id }); transaction.Commit(); } } catch (Exception ex) { transaction.Rollback(); throw new Exception(); } } } else { using (_context) { PersonAsset toUpdateRecord = await(from ps in _context.PersonAsset where ps.Id == request.Id select ps).SingleOrDefaultAsync(); toUpdateRecord.PersonId = request.PersonId; toUpdateRecord.AssetTypeId = request.AssetTypeId; toUpdateRecord.ModifiedOn = request.ModifiedOn; toUpdateRecord.ModifiedBy = request.ModifiedBy; toUpdateRecord.ReferenceNo = request.ReferenceNo; toUpdateRecord.CreatedOn = request.CreatedOn; toUpdateRecord.CreatedBy = request.CreatedBy; toUpdateRecord.Description = request.Description; toUpdateRecord.Value = request.Value; await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new Queries.SearchPersonAssetQuery() { Id = toUpdateRecord.Id }); } } return(result); }
public async Task <List <SearchedPosition> > Handle(SavePositionCommand request, CancellationToken cancellationToken) { List <SearchedPosition> result = new List <SearchedPosition>(); List <Position> list = (from a in _context.Position where a.OrganoGramId == request.OrganoGramId && a.WorkingAreaId == request.WorkingAreaId && a.PositionTypeId == request.PositionTypeId && a.Code == request.Code select a).ToList(); if (list.Any()) { throw new BusinessRulesException("این بست در تشکیل سال انتخاب شده موجود میباشد"); } else { if (request.Id == default(decimal)) { String Sorter = "1"; if (request.ParentId > 0) { Position parent = (from a in _context.Position where a.Id == request.ParentId select a).SingleOrDefault(); String parentsorter = parent.Sorter; int count = (from a in _context.Position where a.ParentId == request.ParentId select a).ToList().Count(); Sorter = parentsorter + '.' + (count + 1).ToString(); } Position PData = new Position() { WorkingAreaId = request.WorkingAreaId, ParentId = request.ParentId, Code = request.Code, PositionTypeId = request.PositionTypeId, LocationId = request.LocationId, SalaryTypeId = request.SalaryTypeId, Sorter = Sorter, OrganoGramId = request.OrganoGramId, PlanTypeId = request.PlanTypeId, }; _context.Position.Add(PData); await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new Queries.SearchPositionQuery() { Id = PData.Id }); } else { Position toUpdateRecord = await(from po in _context.Position where po.Code == request.Code select po).SingleOrDefaultAsync(); toUpdateRecord.WorkingAreaId = request.WorkingAreaId; toUpdateRecord.ParentId = request.ParentId; toUpdateRecord.Code = request.Code; toUpdateRecord.PositionTypeId = request.PositionTypeId; toUpdateRecord.LocationId = request.LocationId; toUpdateRecord.SalaryTypeId = request.SalaryTypeId; // toUpdateRecord.Sorter = "4545"; if (request.ParentId > 0) { Position parent = (from a in _context.Position where a.Id == request.ParentId select a).SingleOrDefault(); String parentsorter = parent.Sorter; int count = (from a in _context.Position where a.ParentId == request.ParentId select a).ToList().Count(); toUpdateRecord.Sorter = parentsorter + '.' + (count + 1).ToString(); } toUpdateRecord.OrganoGramId = request.OrganoGramId; toUpdateRecord.PlanTypeId = request.PlanTypeId; await _context.SaveChangesAsync(cancellationToken); //result = await _mediator.Send(new Queries.SearchPositionQuery() { Id = toUpdateRecord.ParentId }); result = await _mediator.Send(new Queries.SearchPositionQuery() { Id = toUpdateRecord.Id }); } } return(result); }
public async Task <List <SearchedPersonPublication> > Handle(SavePersonPublicationCommand request, CancellationToken cancellationToken) { List <SearchedPersonPublication> result = new List <SearchedPersonPublication>(); if (request.Id == null || request.Id == default(int)) { // Save int CurrentUserId = await _currentUser.GetUserId(); using (var transaction = _context.Database.BeginTransaction()) { try { using (_context) { Publication publication = new Publication() { PersonId = request.PersonId, PublicationTypeId = request.PublicationTypeId, Subject = request.Subject, PublishDate = request.PublishDate, ModifiedOn = request.ModifiedOn, ModifiedBy = request.ModifiedBy, ReferenceNo = request.ReferenceNo, CreatedOn = request.CreatedOn, CreatedBy = request.CreatedBy, Isbn = request.Isbn, NoofPages = request.NoofPages, }; _context.Publication.Add(publication); await _context.SaveChangesAsync(CurrentUserId, cancellationToken); result = await _mediator.Send(new SearchPersonPublicationQuery() { Id = publication.Id }); transaction.Commit(); } } catch (Exception ex) { transaction.Rollback(); throw new Exception(); } } } else { using (_context) { Publication toUpdatePublication = await _context.Publication.Where(ms => ms.Id == request.Id).SingleOrDefaultAsync(); toUpdatePublication.PersonId = request.PersonId; toUpdatePublication.PublicationTypeId = request.PublicationTypeId; toUpdatePublication.Subject = request.Subject; toUpdatePublication.PublishDate = request.PublishDate; toUpdatePublication.ModifiedOn = request.ModifiedOn; toUpdatePublication.ModifiedBy = request.ModifiedBy; toUpdatePublication.ReferenceNo = request.ReferenceNo; toUpdatePublication.CreatedOn = request.CreatedOn; toUpdatePublication.CreatedBy = request.CreatedBy; toUpdatePublication.Isbn = request.Isbn; toUpdatePublication.NoofPages = request.NoofPages; await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new SearchPersonPublicationQuery() { Id = toUpdatePublication.Id }); } } return(result); }
public async Task <List <SearchedPersonHealthReport> > Handle(SavePersonHealthReportCommand request, CancellationToken cancellationToken) { List <SearchedPersonHealthReport> result = new List <SearchedPersonHealthReport>(); if (request.Id == null || request.Id == default(decimal)) { int CurrentUserId = await _currentUser.GetUserId(); using (var transaction = _context.Database.BeginTransaction()) { try { using (_context) { HealthReport healthReport = new HealthReport() { PersonId = request.PersonId, ReportDate = request.ReportDate, StatusId = request.StatusId, ModifiedOn = request.ModifiedOn, ModifiedBy = request.ModifiedBy, ReferenceNo = request.ReferenceNo, CreatedOn = request.CreatedOn, CreatedBy = request.CreatedBy, Approved = request.Approved, Remarks = request.Remarks }; _context.HealthReport.Add(healthReport); await _context.SaveChangesAsync(CurrentUserId, cancellationToken); result = await _mediator.Send(new Queries.SearchPersonHealthReportQuery() { Id = healthReport.Id }); transaction.Commit(); } } catch (Exception ex) { transaction.Rollback(); throw new Exception(); } } } else { using (_context) { HealthReport toUpdateRecord = await(from ph in _context.HealthReport where ph.Id == request.Id select ph).SingleOrDefaultAsync(); toUpdateRecord.PersonId = request.PersonId; toUpdateRecord.ReportDate = request.ReportDate; toUpdateRecord.StatusId = request.StatusId; toUpdateRecord.ModifiedOn = request.ModifiedOn; toUpdateRecord.ModifiedBy = request.ModifiedBy; toUpdateRecord.ReferenceNo = request.ReferenceNo; toUpdateRecord.CreatedOn = request.CreatedOn; toUpdateRecord.CreatedBy = request.CreatedBy; toUpdateRecord.Approved = request.Approved; toUpdateRecord.Remarks = request.Remarks; await _context.SaveChangesAsync(cancellationToken); result = await _mediator.Send(new Queries.SearchPersonHealthReportQuery() { Id = toUpdateRecord.Id }); } } return(result); }