public async Task <BaseEntity> SaveAndReturnEntityAsync(PersonAntiSocialBehaviourDto entityDto) { var personAntiSocialBehaviour = _mapper.Map <PersonAntiSocialBehaviour>(entityDto); var result = await _repository.SaveAndReturnEntityAsync(personAntiSocialBehaviour); result.SuccessMessage = "The data is saved successfully"; return(result); }
public async Task <IActionResult> Put(int id, [FromBody] PersonAntiSocialBehaviourDto personAntiSocialBehaviourDto) { if (id == 0 || personAntiSocialBehaviourDto.Id == 0) { return(StatusCode(StatusCodes.Status400BadRequest, "Id needs to be greater than 0.")); } return(await SaveAndReturnEntityAsync(async() => await _personAntiSocialBehaviourService.SaveAndReturnEntityAsync(personAntiSocialBehaviourDto))); }
public async Task <IActionResult> Post([FromBody] PersonAntiSocialBehaviourDto personAntiSocialBehaviourDto) { if (personAntiSocialBehaviourDto.Id != 0) { return(StatusCode(StatusCodes.Status400BadRequest, "Identity insert is not permitted.")); } return(await SaveAndReturnEntityAsync(async() => await _personAntiSocialBehaviourService.SaveAndReturnEntityAsync(personAntiSocialBehaviourDto))); }
public IActionResult Create(int personId) { var person = _customerFacadeApiClient.GetPerson(personId).Result; var personAntiSocialBehaviour = new PersonAntiSocialBehaviourDto { PersonId = personId, Person = person, ActionDate = DateTime.Now, ActionTimeSelectListItems = SelectedListHelper.GetTimeIntervalForCalendar() }; PopulateLookupFields(personAntiSocialBehaviour); return(PartialView("Edit", personAntiSocialBehaviour)); }
private void PopulateLookupFields(PersonAntiSocialBehaviourDto personAntiSocialBehaviourDto) { var lookups = _lookupApiClient.GetLookupUsingOdata(new List <string> { nameof(LookupDto.AntiSocialBehaviourCaseStatuses), nameof(LookupDto.AntiSocialBehaviourCaseClosureReasons), nameof(LookupDto.AntiSocialBehaviourTypes) }).Result; var model = lookups.value.FirstOrDefault(); if (model != null) { var caseStatuses = model.AntiSocialBehaviourCaseStatuses?.ConvertAll(x => (BaseLookupDto)x); var caseTypes = model.AntiSocialBehaviourTypes?.ConvertAll(x => (BaseLookupDto)x); var caseClosureReasons = model.AntiSocialBehaviourCaseClosureReasons?.ConvertAll(x => (BaseLookupDto)x); personAntiSocialBehaviourDto.CaseStatusSelectListItems = SelectedListHelper.GetSelectListForItems(caseStatuses, personAntiSocialBehaviourDto.CaseStatusId?.ToString()); personAntiSocialBehaviourDto.CaseTypeSelectListItems = SelectedListHelper.GetSelectListForItems(caseTypes, personAntiSocialBehaviourDto.CaseStatusId?.ToString()); personAntiSocialBehaviourDto.CaseClosureReasonSelectListItems = SelectedListHelper.GetSelectListForItems(caseClosureReasons, personAntiSocialBehaviourDto.CaseStatusId?.ToString()); } }
public IActionResult Save(PersonAntiSocialBehaviourDto model) { bool success; if (model.Id == 0) { var time = model.ActionDate.ToShortDateString().Substring(0, 10) + " " + model.ActionTime + ":00"; var date = DateTime.Parse(time); var note = new PersonAntiSocialBehaviourCaseNoteDto { Note = model.Notes, ActionDate = date }; model.PersonAntiSocialBehaviourCaseNotes.Add(note); model = _customerFacadeApiClient.PostPersonAntiSocialBehaviour(model).Result; } else { model = _customerFacadeApiClient.PutPersonAntiSocialBehaviour(model.Id, model).Result; } success = string.IsNullOrWhiteSpace(model.ErrorMessage); return(Json(new { success, message = success ? model.SuccessMessage : model.ErrorMessage })); }
public async Task <PersonAntiSocialBehaviourDto> PutPersonAntiSocialBehaviour(int id, PersonAntiSocialBehaviourDto model) { var url = CRMApiUri + "/PersonAntiSocialBehaviour/" + id; var result = await PutRequestToApi(url, model); return(result); }
public async Task <PersonAntiSocialBehaviourDto> PostPersonAntiSocialBehaviour(PersonAntiSocialBehaviourDto model) { var url = CRMApiUri + "/PersonAntiSocialBehaviour"; var result = await PostRequestToApi(url, model); return(result); }
public async Task <int> SaveAsync(PersonAntiSocialBehaviourDto personAntiSocialBehaviour) { var result = await SaveAndReturnEntityAsync(personAntiSocialBehaviour); return(result.Id); }
public async Task <PersonAntiSocialBehaviourDto> PutPersonAntiSocialBehaviour(int id, PersonAntiSocialBehaviourDto model) { return(await _personAntiSocialBehaviourApiClient.PutPersonAntiSocialBehaviour(id, model)); }
public async Task <PersonAntiSocialBehaviourDto> PostPersonAntiSocialBehaviour(PersonAntiSocialBehaviourDto model) { return(await _personAntiSocialBehaviourApiClient.PostPersonAntiSocialBehaviour(model)); }