//public async Task<IEnumerable<CustomerSuppliedResponseDto>> GetCustomerSuppliedByStartAndEndDate(DateTime startDate, DateTime endDate) //{ // try // { // var customerSupplied = await _customerSuppliedRepository.GetCustomerSuppliedByStartAndEndDate(startDate, endDate); // return customerSupplied; // } // catch (Exception e) // { // Console.WriteLine(e); // throw; // } //} //public async Task<IEnumerable<CustomerSuppliedResponseDto>> GetCustomerSuppliedByCustomerIdAndParticularDate(int customerId, DateTime date) //{ // try // { // return await _customerSuppliedRepository.GetCustomerSuppliedByCustomerIdAndParticularDate(customerId, date); // } // catch (Exception e) // { // Console.WriteLine(e); // throw; // } //} //public async Task<IEnumerable<CustomerSuppliedResponseDto>> GetCustomerSuppliedByCustomerIdStartDateAndEndDate(int customerId, DateTime startDate, DateTime endDate) //{ // try // { // return await _customerSuppliedRepository.GetCustomerSuppliedByCustomerIdStartDateAndEndDate(customerId, startDate, endDate); // } // catch (Exception e) // { // Console.WriteLine(e); // throw; // } //} public async Task <ResponseMessageDto> Delete(CustomerSuppliedRequestDto dto) { try { await _asyncRepository.DeleteAsync(_mapper.Map <CustomerSupplied>(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.InsertionFailureMessage, Success = false, Error = true, ExceptionMessage = e.InnerException != null ? e.InnerException.Message : e.Message }); } }
public async Task <IActionResult> DeleteCustomerSupplied([FromBody] CustomerSuppliedRequestDto dto) { try { return(Ok(await _customerSuppliedService.Delete(dto))); } catch (Exception e) { Console.WriteLine(e); throw; } }
public async Task <ResponseMessageDto> Post(CustomerSuppliedRequestDto dto) { try { if (!_customerSuppliedRepository.IsCustomerRecordAvailableOnParticularDate( dto.CustomerId, dto.CreatedOn.Date)) { var customerCurrentRate = _customerRateRepository.GetCurrentRateByCustomerId(dto.CustomerId); var supply = CustomerSuppliedCalculation.GetMorningSupplyAndAfterNoonSupply(dto.MorningSupply, dto.AfternoonSupply, customerCurrentRate); var sumUp = Convert.ToDouble(supply.morningsupply) + Convert.ToDouble(supply.afternoonSupply); dto.Rate = customerCurrentRate; var credit = sumUp - dto.Debit; dto.Credit = Convert.ToInt32(credit); dto.Total = sumUp; dto.MorningAmount = Convert.ToDouble(supply.morningsupply); dto.AfternoonAmount = Convert.ToDouble(supply.afternoonSupply); var customerSupplied = await _asyncRepository.AddAsync(_mapper.Map <CustomerSupplied>(dto)); return(new ResponseMessageDto() { Id = customerSupplied.Id, SuccessMessage = ResponseMessages.InsertionSuccessMessage, Success = true, Error = false }); } return(new ResponseMessageDto() { Id = Convert.ToInt16(Enums.FailureId), FailureMessage = ResponseMessages.CustomerAlreadyInsertedInThisDate, 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 }); } }
public async Task <IActionResult> Put(CustomerSuppliedRequestDto dto) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok(await _customerSuppliedService.Put(dto))); } catch (Exception e) { Console.WriteLine(e); throw; } }