Beispiel #1
0
        public async Task <IActionResult> UpdateContact([FromBody] ArmsAgencyForUpdateDD agencyforupdate)
        {
            if (agencyforupdate == null)
            {
                return(BadRequest());
            }

            var agencyByIdFromRepo = await _armsDataRepository.GetAgencyByIdAsync(agencyforupdate.AgencyId.Value);

            if (agencyByIdFromRepo == null)
            {
                return(BadRequest());
            }

            agencyforupdate.ActiveInd = agencyforupdate.ActiveInd != "" && agencyforupdate.ActiveInd != null ? agencyforupdate.ActiveInd : "A";
            agencyforupdate.UserId    = agencyforupdate.UserId != "" && agencyforupdate.UserId != null ? agencyforupdate.UserId : "1";
            agencyforupdate.EntryDt   = DateTime.Now;

            var agencyToUpdate = _mapper.Map(agencyforupdate, agencyByIdFromRepo);
            var result         = await _armsDataRepository.UpdateAgency(agencyToUpdate);

            //var agencyFromRepo = await _armsDataRepository.GetAllAgencyAsync();
            // var allAgency = _mapper.Map<IEnumerable<DTOs.ArmsAgencyForDD>>(agencyFromRepo);
            // Ok(allAgency.OrderByDescending(l => l.AgencyId));


            return(Ok(_mapper.Map <DTOs.ArmsAgencyForDD>(agencyToUpdate)));
        }
Beispiel #2
0
        public string DeleteAgency([FromBody] ArmsAgencyForUpdateDD agencyforupdate)
        {
            var agency = _armsDataRepository.GetAgencyByIdAsync(agencyforupdate.AgencyId.Value);

            if (agency != null && agency.Result != null)
            {
                _armsDataRepository.DeleteAgency(agency.Result);
            }
            return("Record deleted successfully");
        }