public async Task <ResponseMessageDto> Delete(MarketSupplierRequestDto dto)
        {
            try
            {
                await _asyncRepository.DeleteAsync(_mapper.Map <MarketSupplier>(dto));

                return(new ResponseMessageDto()
                {
                    Id = dto.Id,
                    SuccessMessage = ResponseMessages.DeleteSuccessMessage,
                    Success = true,
                    Error = false
                });
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(new ResponseMessageDto()
                {
                    Id = Convert.ToInt16(Enums.FailureId),
                    FailureMessage = ResponseMessages.DeleteFailureMessage,
                    Success = false,
                    Error = true,
                    ExceptionMessage = e.InnerException != null ? e.InnerException.Message : e.Message
                });
            }
        }
Beispiel #2
0
 public async Task <IActionResult> Delete([FromBody] MarketSupplierRequestDto dto)
 {
     try
     {
         return(Ok(await _marketSupplierService.Delete(dto)));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Beispiel #3
0
 public async Task <IActionResult> Put([FromBody] MarketSupplierRequestDto dto)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         return(Ok(await _marketSupplierService.Put(dto)));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
        public async Task <ResponseMessageDto> Put(MarketSupplierRequestDto dto)
        {
            try
            {
                if (await _marketSupplierRepository.IsMarketSupplierNameAvailable(dto.Id, dto.MarketSupplierName))
                {
                    return new ResponseMessageDto()
                           {
                               SuccessMessage = ResponseMessages.MarketSupplierNameNotAvailable,
                               Success        = true,
                               Error          = false
                           }
                }
                ;
                await _asyncRepository.PartialUpdate(dto, m => ///yahan woh values aengi jo ke update karni hongi
                {
                    m.MarketSupplierName    = dto.MarketSupplierName;
                    m.MarketSupplierAddress = dto.MarketSupplierAddress;
                    m.MarketSupplierContact = dto.MarketSupplierContact;
                });

                return(new ResponseMessageDto()
                {
                    Id = dto.Id,
                    SuccessMessage = ResponseMessages.UpdateSuccessMessage,
                    Success = true,
                    Error = false
                });
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(new ResponseMessageDto()
                {
                    Id = Convert.ToInt16(Enums.FailureId),
                    FailureMessage = ResponseMessages.UpdateFailureMessage,
                    Success = false,
                    Error = true,
                    ExceptionMessage = e.InnerException != null ? e.InnerException.Message : e.Message
                });
            }
        }
        public async Task <ResponseMessageDto> Post(MarketSupplierRequestDto dto)
        {
            try
            {
                if (await _marketSupplierRepository.IsMarketSupplierNameAvailable(dto.MarketSupplierName))
                {
                    return new ResponseMessageDto()
                           {
                               FailureMessage = ResponseMessages.MarketSupplierNameNotAvailable,
                               Success        = false,
                               Error          = true
                           }
                }
                ;
                dto.CreatedOn = DateTime.Now.Date;
                var markerSupplier = await _asyncRepository.AddAsync(_mapper.Map <MarketSupplier>(dto));

                return(new ResponseMessageDto()
                {
                    Id = markerSupplier.Id,
                    SuccessMessage = ResponseMessages.InsertionSuccessMessage,
                    Success = true,
                    Error = false
                });
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(new ResponseMessageDto()
                {
                    Id = Convert.ToInt16(Enums.FailureId),
                    FailureMessage = ResponseMessages.InsertionFailureMessage,
                    Success = false,
                    Error = true,
                    ExceptionMessage = e.InnerException != null ? e.InnerException.Message : e.Message
                });
            }
        }