Exemple #1
0
        public async Task <BaseEntity> SaveAndReturnEntityAsync(PersonAlertCommentDto entityDto)
        {
            var personAlertComment = _mapper.Map <PersonAlertComment>(entityDto);

            if (entityDto.PersonAlert != null)
            {
                var personAlert = _repository.CRMContext.PersonAlerts.FirstOrDefaultAsync(x => x.Id == entityDto.PersonAlertId).Result;
                if (personAlert.AlertStatusId != entityDto.PersonAlert.AlertStatusId)
                {
                    personAlert.AlertStatusId = entityDto.PersonAlert.AlertStatusId;
                    await _repository.SaveAndReturnEntityAsync(personAlert);
                }
                personAlertComment.PersonAlert = null;
            }
            if (entityDto.Id == 0)
            {
                var loggedUsed = _repository.CRMContext.IdentityUserView.FirstOrDefault(
                    x => x.Id == _repository.CRMContext.CurrentLoggedUserId);
                personAlertComment.CreatedBy = loggedUsed?.FirstName + " " + loggedUsed?.LastName;
                personAlertComment.CreatedOn = DateTime.Now;
            }
            var result = await _repository.SaveAndReturnEntityAsync(personAlertComment);

            result.SuccessMessage = "The data is saved successfully";
            return(result);
        }
Exemple #2
0
        public async Task <PersonAlertCommentDto> PutPersonAlertComment(int id, PersonAlertCommentDto model)
        {
            var url    = CRMApiUri + "/PersonAlertComment/" + id;
            var result = await PutRequestToApi(url, model);

            return(result);
        }
Exemple #3
0
        public async Task <PersonAlertCommentDto> PostPersonAlertComment(PersonAlertCommentDto model)
        {
            var url    = CRMApiUri + "/PersonAlertComment";
            var result = await PostRequestToApi(url, model);

            return(result);
        }
Exemple #4
0
        public IActionResult Save(PersonAlertCommentDto model)
        {
            bool success;

            model = model.Id == 0 ? _customerFacadeApiClient.PostPersonAlertComment(model).Result
                : _customerFacadeApiClient.PutPersonAlertComment(model.Id, model).Result;
            success = string.IsNullOrWhiteSpace(model.ErrorMessage);
            return(Json(new { success, message = success ? model.SuccessMessage : model.ErrorMessage }));
        }
Exemple #5
0
        public async Task <IActionResult> Put(int id, [FromBody] PersonAlertCommentDto personAlertCommentDto)
        {
            if (id == 0 || personAlertCommentDto.Id == 0)
            {
                return(StatusCode(StatusCodes.Status400BadRequest, "Id needs to be greater than 0."));
            }

            return(await SaveAndReturnEntityAsync(async() => await _personAlertCommentService.SaveAndReturnEntityAsync(personAlertCommentDto)));
        }
Exemple #6
0
        public async Task <IActionResult> Post([FromBody] PersonAlertCommentDto personAlertCommentDto)
        {
            if (personAlertCommentDto.Id != 0)
            {
                return(StatusCode(StatusCodes.Status400BadRequest, "Identity insert is not permitted."));
            }

            return(await SaveAndReturnEntityAsync(async() => await _personAlertCommentService.SaveAndReturnEntityAsync(personAlertCommentDto)));
        }
Exemple #7
0
        public IActionResult Create(int personAlertId)
        {
            var personAlert = _customerFacadeApiClient.GetPersonAlert(personAlertId).Result;

            PopulateLookupFields(personAlert);
            var personAlertComment = new PersonAlertCommentDto {
                PersonAlertId = personAlertId, PersonAlert = personAlert
            };

            return(PartialView("Edit", personAlertComment));
        }
Exemple #8
0
 public async Task <PersonAlertCommentDto> PutPersonAlertComment(int id, PersonAlertCommentDto model)
 {
     return(await _personAlertCommentApiClient.PutPersonAlertComment(id, model));
 }
Exemple #9
0
 public async Task <PersonAlertCommentDto> PostPersonAlertComment(PersonAlertCommentDto model)
 {
     return(await _personAlertCommentApiClient.PostPersonAlertComment(model));
 }
Exemple #10
0
        public async Task <int> SaveAsync(PersonAlertCommentDto personAlertComment)
        {
            var result = await SaveAndReturnEntityAsync(personAlertComment);

            return(result.Id);
        }