Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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)));
        }
Ejemplo n.º 3
0
        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)));
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        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());
            }
        }
Ejemplo n.º 6
0
        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 }));
        }
Ejemplo n.º 7
0
        public async Task <PersonAntiSocialBehaviourDto> PutPersonAntiSocialBehaviour(int id, PersonAntiSocialBehaviourDto model)
        {
            var url    = CRMApiUri + "/PersonAntiSocialBehaviour/" + id;
            var result = await PutRequestToApi(url, model);

            return(result);
        }
Ejemplo n.º 8
0
        public async Task <PersonAntiSocialBehaviourDto> PostPersonAntiSocialBehaviour(PersonAntiSocialBehaviourDto model)
        {
            var url    = CRMApiUri + "/PersonAntiSocialBehaviour";
            var result = await PostRequestToApi(url, model);

            return(result);
        }
Ejemplo n.º 9
0
        public async Task <int> SaveAsync(PersonAntiSocialBehaviourDto personAntiSocialBehaviour)
        {
            var result = await SaveAndReturnEntityAsync(personAntiSocialBehaviour);

            return(result.Id);
        }
Ejemplo n.º 10
0
 public async Task <PersonAntiSocialBehaviourDto> PutPersonAntiSocialBehaviour(int id, PersonAntiSocialBehaviourDto model)
 {
     return(await _personAntiSocialBehaviourApiClient.PutPersonAntiSocialBehaviour(id, model));
 }
Ejemplo n.º 11
0
 public async Task <PersonAntiSocialBehaviourDto> PostPersonAntiSocialBehaviour(PersonAntiSocialBehaviourDto model)
 {
     return(await _personAntiSocialBehaviourApiClient.PostPersonAntiSocialBehaviour(model));
 }