예제 #1
0
        public async Task <PersonCaseDto> PutPersonCase(int id, PersonCaseDto model)
        {
            var url    = CRMApiUri + "/PersonCase/" + id;
            var result = await PutRequestToApi(url, model);

            return(result);
        }
예제 #2
0
        public async Task <PersonCaseDto> PostPersonCase(PersonCaseDto model)
        {
            var url    = CRMApiUri + "/PersonCase";
            var result = await PostRequestToApi(url, model);

            return(result);
        }
예제 #3
0
        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 }));
        }
예제 #4
0
        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)));
        }
예제 #5
0
        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)));
        }
예제 #6
0
        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));
        }
예제 #7
0
        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);
        }
예제 #8
0
        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());
            }
        }
예제 #9
0
 public async Task <PersonCaseDto> PutPersonCase(int id, PersonCaseDto model)
 {
     return(await _personCaseApiClient.PutPersonCase(id, model));
 }
예제 #10
0
 public async Task <PersonCaseDto> PostPersonCase(PersonCaseDto model)
 {
     return(await _personCaseApiClient.PostPersonCase(model));
 }
예제 #11
0
        public async Task <int> SaveAsync(PersonCaseDto personCase)
        {
            var result = await SaveAndReturnEntityAsync(personCase);

            return(result.Id);
        }