public async Task <PersonCaseDto> PutPersonCase(int id, PersonCaseDto model) { var url = CRMApiUri + "/PersonCase/" + id; var result = await PutRequestToApi(url, model); return(result); }
public async Task <PersonCaseDto> PostPersonCase(PersonCaseDto model) { var url = CRMApiUri + "/PersonCase"; var result = await PostRequestToApi(url, model); return(result); }
public IActionResult Save(PersonCaseDto model) { bool success; model = model.Id == 0 ? _customerFacadeApiClient.PostPersonCase(model).Result : _customerFacadeApiClient.PutPersonCase(model.Id, model).Result; success = string.IsNullOrWhiteSpace(model.ErrorMessage); return(Json(new { success, message = success ? model.SuccessMessage : model.ErrorMessage })); }
public async Task <IActionResult> Put(int id, [FromBody] PersonCaseDto personCaseDto) { if (id == 0 || personCaseDto.Id == 0) { return(StatusCode(StatusCodes.Status400BadRequest, "Id needs to be greater than 0.")); } return(await SaveAndReturnEntityAsync(async() => await _personCaseService.SaveAndReturnEntityAsync(personCaseDto))); }
public async Task <IActionResult> Post([FromBody] PersonCaseDto personCaseDto) { if (personCaseDto.Id != 0) { return(StatusCode(StatusCodes.Status400BadRequest, "Identity insert is not permitted.")); } return(await SaveAndReturnEntityAsync(async() => await _personCaseService.SaveAndReturnEntityAsync(personCaseDto))); }
public IActionResult Create(int personId) { var person = _customerFacadeApiClient.GetPerson(personId).Result; var personCase = new PersonCaseDto { PersonId = personId, Person = person }; PopulateLookupFields(personCase); return(PartialView("Edit", personCase)); }
public async Task <BaseEntity> SaveAndReturnEntityAsync(PersonCaseDto entityDto) { var personCase = _mapper.Map <PersonCase>(entityDto); if (entityDto.Id == 0) { var loggedUsed = _repository.CRMContext.IdentityUserView.FirstOrDefault( x => x.Id == _repository.CRMContext.CurrentLoggedUserId); personCase.CreatedBy = loggedUsed?.FirstName + " " + loggedUsed?.LastName; personCase.CreatedOn = DateTime.Now; } var result = await _repository.SaveAndReturnEntityAsync(personCase); result.SuccessMessage = "The data is saved successfully"; return(result); }
private void PopulateLookupFields(PersonCaseDto personCase) { var lookups = _lookupApiClient.GetLookupUsingOdata(new List <string> { nameof(LookupDto.Priorities), nameof(LookupDto.PersonCaseTypes), nameof(LookupDto.PersonCaseStatuses) }).Result; var model = lookups.value.FirstOrDefault(); if (model != null) { var caseStatuses = model.PersonCaseStatuses?.Where(x => x.IsActive).ToList().ConvertAll(x => (BaseLookupDto)x); var caseTypes = model.PersonCaseTypes?.Where(x => x.IsActive).ToList().ConvertAll(x => (BaseLookupDto)x); var priorities = model.Priorities?.Where(x => x.IsActive).ToList().ConvertAll(x => (BaseLookupDto)x); personCase.CaseStatusSelectList = SelectedListHelper.GetSelectListForItems(caseStatuses, personCase.CaseStatusId?.ToString()); personCase.CaseTypeSelectList = SelectedListHelper.GetSelectListForItems(caseTypes, personCase.CaseStatusId?.ToString()); personCase.PrioritySelectList = SelectedListHelper.GetSelectListForItems(priorities, personCase.CaseStatusId?.ToString()); } }
public async Task <PersonCaseDto> PutPersonCase(int id, PersonCaseDto model) { return(await _personCaseApiClient.PutPersonCase(id, model)); }
public async Task <PersonCaseDto> PostPersonCase(PersonCaseDto model) { return(await _personCaseApiClient.PostPersonCase(model)); }
public async Task <int> SaveAsync(PersonCaseDto personCase) { var result = await SaveAndReturnEntityAsync(personCase); return(result.Id); }