public async Task <IActionResult> GetAll([FromQuery] PageParams pageParams, [FromBody] BillMasterModel getBillMasterModel) { ServiceResponseModel <IEnumerable <BillMaster> > response = new ServiceResponseModel <IEnumerable <BillMaster> >(); try { if (string.IsNullOrWhiteSpace(getBillMasterModel.CompCode)) { throw new ArgumentNullException("CompCode is required"); } if (string.IsNullOrWhiteSpace(getBillMasterModel.AccYear)) { throw new ArgumentNullException("AccYear is required"); } var billMasterList = await _billMasterService.GetAll(pageParams, getBillMasterModel); Response.AddPaginationHeader(billMasterList.CurrentPage, billMasterList.PageSize, billMasterList.TotalCount, billMasterList.TotalPages); response.Data = billMasterList; } catch (System.Exception ex) { _logger.LogError(ex.StackTrace); response.Success = false; response.Message = ex.Message; } return(Ok(response)); }
public async Task <PagedList <BillMaster> > GetAll(PageParams pageParams, BillMasterModel getBillMasterModel) { var query = _context.BillMasters .Where(a => a.CompCode == getBillMasterModel.CompCode && a.AccYear == getBillMasterModel.AccYear) .AsQueryable(); switch (getBillMasterModel.OrderBy) { case "billId": query = query.OrderBy(c => c.CompCode).ThenBy(c => c.AccYear).ThenBy(c => c.BillId); break; case "accountId": query = query.OrderBy(c => c.CompCode).ThenBy(c => c.AccYear).ThenBy(c => c.BillId).ThenBy(c => c.AccountId); break; case "billDate": query = query.OrderBy(c => c.CompCode).ThenBy(c => c.AccYear).ThenBy(c => c.BillId).ThenBy(c => c.AccountId).ThenBy(c => c.BillDate); break; default: query = query.OrderBy(c => c.CompCode).ThenBy(c => c.AccYear).ThenBy(c => c.BillId); break; } return(await PagedList <BillMaster> .CreateAsync(query, pageParams.PageNumber, pageParams.PageSize)); }
public async Task <IActionResult> GetAll([FromBody] BillMasterModel getBillMasterModel) { ServiceResponseModel <IEnumerable <BillMasterModel> > response = new ServiceResponseModel <IEnumerable <BillMasterModel> >(); try { if (string.IsNullOrWhiteSpace(getBillMasterModel.CompCode)) { throw new ArgumentNullException("CompCode is required"); } if (string.IsNullOrWhiteSpace(getBillMasterModel.AccYear)) { throw new ArgumentNullException("AccYear is required"); } response = await _billMasterService.GetAll(getBillMasterModel); if (response.Data == null) { return(NotFound(response)); } } catch (System.Exception ex) { _logger.LogError(ex.StackTrace); response.Success = false; response.Message = ex.Message; } return(Ok(response)); }
// GET: BillDetails/Edit/5 public async Task <IActionResult> Edit(int?id) { var billMasterDetails = _context.BillMaster; List <BillMasterModel> billMasterList = new List <BillMasterModel>(); if (billMasterDetails != null) { foreach (var bills in billMasterDetails) { BillMasterModel billMaster = new BillMasterModel(); billMaster.BillId = bills.BillId; billMaster.BillName = bills.BillName; billMasterList.Add(billMaster); } } ViewData["BillMaterDdl"] = new SelectList(billMasterList, "BillId", "BillName"); if (id == null) { return(NotFound()); } var billDetailsModel = await _context.BillDetails.SingleOrDefaultAsync(m => m.BillDetailId == id); if (billDetailsModel == null) { return(NotFound()); } return(View(billDetailsModel)); }
public async Task <ServiceResponseModel <BillMasterModel> > Add(BillMasterModel newBillMasterModel) { ServiceResponseModel <BillMasterModel> serviceResponse = new ServiceResponseModel <BillMasterModel>(); BillMaster billMaster = _mapper.Map <BillMaster>(newBillMasterModel); await UnitOfWork.BillMasters.AddAsync(billMaster); await UnitOfWork.Complete(); serviceResponse.Data = newBillMasterModel; return(serviceResponse); }
public async Task <ServiceResponseModel <BillMasterModel> > Delete(BillMasterModel billMasterModel) { ServiceResponseModel <BillMasterModel> serviceResponse = new ServiceResponseModel <BillMasterModel>(); BillMaster delBillMaster = await UnitOfWork.BillMasters.SingleOrDefaultAsync(a => a.CompCode == billMasterModel.CompCode && a.AccYear == billMasterModel.AccYear && a.BillId == billMasterModel.BillId && a.AccountId == billMasterModel.AccountId); UnitOfWork.BillMasters.Remove(delBillMaster); await UnitOfWork.Complete(); serviceResponse.Data = billMasterModel; return(serviceResponse); }
public async Task <ServiceResponseModel <BillMasterModel> > Edit(BillMasterModel editBillMasterModel) { ServiceResponseModel <BillMasterModel> serviceResponse = new ServiceResponseModel <BillMasterModel>(); BillMaster editBillMaster = await UnitOfWork.BillMasters.SingleOrDefaultAsync(a => a.CompCode == editBillMasterModel.CompCode && a.AccYear == editBillMasterModel.AccYear && a.BillId == editBillMasterModel.BillId && a.AccountId == editBillMasterModel.AccountId); _mapper.Map <BillMasterModel, BillMaster>(editBillMasterModel, editBillMaster); UnitOfWork.BillMasters.Update(editBillMaster); await UnitOfWork.Complete(); serviceResponse.Data = editBillMasterModel; return(serviceResponse); }
public async Task <ServiceResponseModel <BillMasterModel> > GetBillId(BillMasterModel billMasterId) { ServiceResponseModel <BillMasterModel> serviceResponse = new ServiceResponseModel <BillMasterModel>(); BillMaster editBillMaster = await _context.BillMasters .Include(b => b.BillDetails) .Include(b => b.VoucherMasters) .Where(a => a.CompCode == billMasterId.CompCode && a.AccYear == billMasterId.AccYear && a.BillId == billMasterId.BillId && a.AccountId == billMasterId.AccountId) .SingleAsync(); BillMasterModel billMasterModel = _mapper.Map <BillMasterModel>(editBillMaster); serviceResponse.Data = billMasterModel; return(serviceResponse); }
// GET: BillDetails //ViewData to populate ddl values public IActionResult Transactions(int BillMasterId) { var billMasterDetails = _context.BillMaster; List <BillMasterModel> billMasterList = new List <BillMasterModel>(); if (billMasterDetails != null) { foreach (var bills in billMasterDetails) { BillMasterModel billMaster = new BillMasterModel(); billMaster.BillId = bills.BillId; billMaster.BillName = bills.BillName; billMasterList.Add(billMaster); } } ViewData["BillMaterDdl"] = new SelectList(billMasterList, "BillId", "BillName"); return(View()); }
public async Task <ServiceResponseModel <IEnumerable <BillMasterModel> > > GetAll(BillMasterModel getBillMasterModel) { ServiceResponseModel <IEnumerable <BillMasterModel> > serviceResponse = new ServiceResponseModel <IEnumerable <BillMasterModel> >(); IEnumerable <BillMaster> getBillMaster = await UnitOfWork.BillMasters.FindAsync(a => a.CompCode == getBillMasterModel.CompCode && a.AccYear == getBillMasterModel.AccYear); IEnumerable <BillMasterModel> billMasterModel = _mapper.Map <IEnumerable <BillMasterModel> >(getBillMaster); serviceResponse.Data = billMasterModel; return(serviceResponse); }