public async Task <ResponseMessageDto> Delete(MarketSellRequestDto dto)
        {
            try
            {
                await _asyncRepository.DeleteAsync(_mapper.Map <MarketSell>(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
                });
            }
        }
Exemplo n.º 2
0
 public async Task <IActionResult> Delete([FromBody] MarketSellRequestDto dto)
 {
     try
     {
         return(Ok(await _marketSellService.Delete(dto)));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
        public async Task <ResponseMessageDto> Post(MarketSellRequestDto dto)
        {
            try
            {
                if (!await _marketSell.IsMarketSupplierInsertedOnCurrentDate(dto.MarketSupplierId))
                {
                    var(morningsupply, afternoonSupply) =
                        MarketSellCalculate.GetMorningSupplyAndAfterNoonSupply(dto.MorningSell,
                                                                               dto.AfternoonSell, Convert.ToInt32(dto.MorningRate), Convert.ToInt32(dto.AfternoonRate));
                    var sumUp = Convert.ToDouble(morningsupply) +
                                Convert.ToDouble(afternoonSupply);
                    int    addAllComissionValues = SupplierCommissionCalculate.SupplierComissionCalulate(dto.MorningSell, dto.AfternoonSell, dto.ComissionRate);
                    string grandMilkTotal        = TotalMilkCalculate.TotalMilkCalulate(dto.MorningSell, dto.AfternoonSell);
                    dto.MorningAmount   = morningsupply;
                    dto.AfternoonAmount = afternoonSupply;
                    dto.TotalComission  = addAllComissionValues;
                    dto.Total           = sumUp.ToString();
                    dto.TotalMilk       = grandMilkTotal;
                    dto.CreatedOn       = dto.CreatedOn;
                    var marketSell = await _asyncRepository.AddAsync(_mapper.Map <MarketSell>(dto));

                    return(new ResponseMessageDto()
                    {
                        Id = marketSell.Id,
                        SuccessMessage = ResponseMessages.InsertionSuccessMessage,
                        Success = true,
                        Error = false
                    });
                }
                return(new ResponseMessageDto()
                {
                    Id = Convert.ToInt16(Enums.FailureId),
                    FailureMessage = ResponseMessages.SupplierAlreadyInsertedInThisDate,
                    Success = false,
                    Error = true
                });
            }
            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
                });
            }
        }
Exemplo n.º 4
0
 public async Task <IActionResult> Put([FromBody] MarketSellRequestDto dto)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         return(Ok(await _marketSellService.Put(dto)));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
        public async Task <ResponseMessageDto> Put(MarketSellRequestDto dto)
        {
            try
            {
                if (!await _marketSell.IsMarketSupplierInsertedOnCurrentDate(dto.MarketSupplierId,
                                                                             dto.Id))
                {
                    var(morningsupply, afternoonSupply) =
                        MarketSellCalculate.GetMorningSupplyAndAfterNoonSupply(dto.MorningSell,
                                                                               dto.AfternoonSell, Convert.ToInt32(dto.MorningRate), Convert.ToInt32(dto.AfternoonRate));
                    var sumUp = Convert.ToDouble(morningsupply) +
                                Convert.ToDouble(afternoonSupply);
                    int    addAllComissionValues = SupplierCommissionCalculate.SupplierComissionCalulate(dto.MorningSell, dto.AfternoonSell, dto.ComissionRate);
                    string grandMilkTotal        = TotalMilkCalculate.TotalMilkCalulate(dto.MorningSell, dto.AfternoonSell);
                    dto.MorningAmount   = morningsupply;
                    dto.AfternoonAmount = afternoonSupply;
                    dto.TotalComission  = addAllComissionValues;
                    dto.Total           = sumUp.ToString();
                    dto.TotalMilk       = grandMilkTotal;

                    await _asyncRepository.PartialUpdate(dto, m => ///yahan woh values aengi jo ke update karni hongi
                    {
                        m.MarketSupplierId = dto.MarketSupplierId;
                        m.MorningSell      = dto.MorningSell;
                        m.MorningRate      = dto.MorningRate;
                        m.MorningAmount    = dto.MorningAmount;
                        m.AfternoonSell    = dto.AfternoonSell;
                        m.AfternoonAmount  = dto.AfternoonAmount;
                        m.AfternoonRate    = dto.AfternoonRate;
                        m.ComissionRate    = dto.ComissionRate;
                        m.TotalComission   = dto.TotalComission;
                        m.Total            = dto.Total;
                        m.TotalMilk        = dto.TotalMilk;
                    });

                    return(new ResponseMessageDto()
                    {
                        Id = dto.Id,
                        SuccessMessage = ResponseMessages.UpdateSuccessMessage,
                        Success = true,
                        Error = false
                    });
                }
                return(new ResponseMessageDto()
                {
                    Id = Convert.ToInt16(Enums.FailureId),
                    FailureMessage = ResponseMessages.SupplierAlreadyInsertedInThisDate,
                    Success = false,
                    Error = true
                });
            }
            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
                });
            }
        }