public VoucherModel GetVoucherTypeInfo() { VoucherModel voucher = new VoucherModel(); SqlDataReader SqlDtr = null; voucher.VoucherID = 0; dbobj.SelectQuery("Select max(Voucher_ID) from Voucher_Transaction where Voucher_Type ='Contra'", ref SqlDtr); if (SqlDtr.Read()) { voucher.Contra = SqlDtr.GetValue(0).ToString(); } SqlDtr.Close(); dbobj.SelectQuery("Select max(Voucher_ID) from Voucher_Transaction where Voucher_Type ='Credit Note'", ref SqlDtr); if (SqlDtr.Read()) { voucher.Credit = SqlDtr.GetValue(0).ToString(); } SqlDtr.Close(); dbobj.SelectQuery("Select max(Voucher_ID) from Voucher_Transaction where Voucher_Type ='Debit Note'", ref SqlDtr); if (SqlDtr.Read()) { voucher.Debit = SqlDtr.GetValue(0).ToString(); } SqlDtr.Close(); dbobj.SelectQuery("Select max(Voucher_ID) from Voucher_Transaction where Voucher_Type ='Journal'", ref SqlDtr); if (SqlDtr.Read()) { voucher.Journal = SqlDtr.GetValue(0).ToString(); } SqlDtr.Close(); return(voucher); }
public IHttpActionResult PostVoucher(VoucherModel voucher) { if (!ModelState.IsValid || voucher.OfferID == null || voucher.BuyerID == null) { return(BadRequest(ModelState)); } OfferModel offer = offersService.GetOffer((int)voucher.OfferID); UserModel buyer = usersService.GetUser((int)voucher.BuyerID); if (offer == null || buyer == null) { return(NotFound()); } if (buyer.UserRole != UserRoles.ROLE_CUSTOMER) { return(BadRequest("User's role must be ROLE_CUSTOMER")); } voucher.Offer = offer; voucher.Buyer = buyer; VoucherModel createdVoucher = vouchersService.CreateVoucher(voucher); return(CreatedAtRoute("PostVoucher", new { id = createdVoucher.ID }, createdVoucher)); }
public async Task <ActionResult <VoucherModel> > Put(int AccountId, int Id, VoucherModel updatedModel) { try { var currentVoucher = await _repository.GetVoucherAsync(AccountId, Id); if (currentVoucher == null) { return(NotFound($"Could not find Voucher with Id of {Id}")); } _mapper.Map(updatedModel, currentVoucher); if (await _repository.UpdateVoucherAsync(AccountId, currentVoucher)) { return(_mapper.Map <VoucherModel>(currentVoucher)); } } catch (Exception e) { _logger.LogError(e, e.Message); return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } return(BadRequest()); }
public async Task <ActionResult <VoucherModel> > Post(int AccountId, VoucherModel model) { try { //Make sure VoucherId is not already taken var existing = await _repository.GetVoucherAsync(AccountId, model.Id); if (existing != null) { return(BadRequest("Voucher Id in Use")); } //map var Voucher = _mapper.Map <Voucher>(model); //save and return if (!await _repository.StoreNewVoucherAsync(AccountId, Voucher)) { return(BadRequest("Bad request, could not create record!")); } else { var location = _linkGenerator.GetPathByAction("Get", "Voucher", new { Voucher.AccountId, Voucher.Id }); return(Created(location, _mapper.Map <VoucherModel>(Voucher))); } } catch (Exception e) { _logger.LogError(e, e.Message); return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } }
public IHttpActionResult DeleteVoucher(VoucherModel voucher) { int c = 0; dbobj.Insert_or_Update("delete from voucher_Transaction where voucher_id =" + voucher.VoucherID, ref c); if (voucher.VoucherType.Equals("Contra")) { dbobj.Insert_or_Update("delete from AccountsLedgerTable where Particulars ='Contra (" + voucher.VoucherID + ")'", ref c); } else if (voucher.VoucherType.Equals("Journal")) { dbobj.Insert_or_Update("delete from AccountsLedgerTable where Particulars ='Journal (" + voucher.VoucherID + ")'", ref c); } else if (voucher.VoucherType.Equals("Credit Note")) { dbobj.Insert_or_Update("delete from AccountsLedgerTable where Particulars ='Credit Note (" + voucher.VoucherID + ")'", ref c); } else if (voucher.VoucherType.Equals("Debit Note")) { dbobj.Insert_or_Update("delete from AccountsLedgerTable where Particulars ='Debit Note (" + voucher.VoucherID + ")'", ref c); } dbobj.Insert_or_Update("delete from CustomerLedgerTable where Particular ='Voucher(" + voucher.VoucherID + ")'", ref c); if (c > 0) { return(Ok(c)); } else { return(Content(HttpStatusCode.NotFound, "Voucher is not deleted")); } }
public ActionResult DeleteVoucherList(int id) { VoucherModel voucherModel = new VoucherModel(connectionString); voucherModel.DeleteVoucherList(id); return(View()); }
//Dapper method to use code param to get voucher from database.. public static async Task <VoucherModel> GetVoucherAsync(string code) { VoucherModel voucher = new VoucherModel(); using (var conn = Connection) { if (conn.State == System.Data.ConnectionState.Closed) { conn.Open(); } IDataReader reader = await conn.ExecuteReaderAsync("GetVoucherByCode", new { Code = code }, commandType : CommandType.StoredProcedure); //Reader appending the values while stream is open to print out while (reader.Read()) { voucher.Code = reader["code"].ToString(); voucher.Amount = Convert.ToInt64(reader["giftAmount"].ToString()); } reader.Close(); } return(voucher); }
public IHttpActionResult PostVoucherModel(VoucherModel voucher) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} //VoucherModel createdVoucher = voucherService.CreateVoucher(voucherModel); //return CreatedAtRoute("SingleVoucherById", new { id = createdVoucher.id }, createdVoucher); if (!ModelState.IsValid || voucher.offerId == null || voucher.userId == null) { return(BadRequest(ModelState)); } OfferModel offer = offerService.GetOffer((int)voucher.offerId); UserModel buyer = userService.GetUser((int)voucher.userId); if (offer == null || buyer == null) { return(NotFound()); } if (buyer.user_role != UserModel.UserRoles.ROLE_CUSTOMER) { return(BadRequest("User's role must be ROLE_CUSTOMER")); } voucher.offerModel = offer; voucher.userModel = buyer; VoucherModel createdVoucher = voucherService.CreateVoucher(voucher); return(CreatedAtRoute("PostVoucher", new { id = createdVoucher.id }, createdVoucher)); }
public void CalculateBasketTotal() { //setUp VoucherModel _voucher = new VoucherModel(); List <ProductModel> _productList = new List <ProductModel>(); _productList.Add(new ProductModel() { id = Guid.NewGuid(), description = "Green Apple", price = 2, type = Enumeration.ProductTypes.Apples }); _productList.Add(new ProductModel() { id = Guid.NewGuid(), description = "Green Apple", price = 2, type = Enumeration.ProductTypes.Apples }); _productList.Add(new ProductModel() { id = Guid.NewGuid(), description = "Green Apple", price = 2, type = Enumeration.ProductTypes.Apples }); _productList.Add(new ProductModel() { id = Guid.NewGuid(), description = "Orange", price = 2, type = Enumeration.ProductTypes.Oranges }); _productList.Add(new ProductModel() { id = Guid.NewGuid(), description = "Orange", price = 2, type = Enumeration.ProductTypes.Oranges }); _voucher.id = Guid.NewGuid(); _voucher.desctription = "This is a two for the price of one voucher"; _voucher.identifier = Enumeration.VoucherTypes.TwoForOne; using (var container = BuildIOCContainer()) { var basket = container.GetService <IBasket>(); //Action var basketModel = basket.CalculateBasketTotal(_productList, _voucher); //asserts Assert.AreEqual(8, basketModel.totalPrice, "Totals do not match!"); } }
public IHttpActionResult GetVoucherById(int id) { VoucherModel voucher = voucherService.GetVoucherById(id); if (voucher == null) { return(NotFound()); } return(Ok(voucher)); }
public VoucherModel CreateVoucher(VoucherModel voucher) { voucher.IsUsed = false; voucher.ExpirationDate = (DateTime.UtcNow.AddDays(7)); db.VouchersRepository.Insert(voucher); db.Save(); return(voucher); }
public void PostVoucher(BillModel bill) { VoucherModel voucher = new VoucherModel() { User = bill.User, Offer = bill.Offer, IsUsed = false, ExpirationDate = DateTime.UtcNow.AddDays(7) }; }
public IHttpActionResult DeleteVoucher(int id) { VoucherModel voucher = voucherService.DeleteVoucher(id); if (voucher == null) { return(NotFound()); } return(Ok(voucher)); }
public VoucherModel CreateVoucher(VoucherModel voucher) { // Mladen voucher.isUsed = false; voucher.expirationDate = DateTime.UtcNow.AddDays(7); db.VouchersRepository.Insert(voucher); db.Save(); return(voucher); }
public IHttpActionResult GetVoucherModel(int id) { VoucherModel voucherModel = db.VoucherRepository.GetByID(id); if (voucherModel == null) { return(NotFound()); } return(Ok(voucherModel)); }
public IHttpActionResult PostVoucherModel(VoucherModel voucherModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.VoucherRepository.Insert(voucherModel); db.Save(); return(CreatedAtRoute("SingleVoucherById", new { id = voucherModel.id }, voucherModel)); }
public VoucherModel DeleteVoucher(int id) { VoucherModel voucher = db.VouchersRepository.GetByID(id); if (voucher != null) { db.VouchersRepository.Delete(voucher); db.Save(); } return(voucher); }
public IHttpActionResult InsertVoucher(VoucherModel Voucher) { int c = 0; dbobj.Insert_or_Update("Insert into Voucher_Transaction values(" + Voucher.VoucherID + ",'" + Voucher.VoucherType + "',Convert(datetime,'" + Voucher.VoucherDate + "',103)," + Voucher.LedgerIDCr + "," + Voucher.Amount1 + "," + Voucher.LedgerIDDr + "," + Voucher.Amount2 + ",'" + Voucher.Narration + "','" + Voucher.LType + "')", ref c); object obj = null; dbobj.ExecProc(App_Start.DbOperations_LATEST.OprType.Insert, "ProInsertAccountsLedger", ref obj, "@Ledger_ID", Voucher.LedgerIDDr, "@Particulars", Voucher.VoucherType + " (" + Voucher.VoucherID + ")", "@Debit_Amount", Voucher.Amount2, "@Credit_Amount", "0.0", "@type", "Dr", "@Invoice_Date", Convert.ToDateTime(Voucher.InvoiceDate)); dbobj.ExecProc(App_Start.DbOperations_LATEST.OprType.Insert, "ProInsertAccountsLedger", ref obj, "@Ledger_ID", Voucher.LedgerIDCr, "@Particulars", Voucher.VoucherType + " (" + Voucher.VoucherID + ")", "@Debit_Amount", "0.0", "@Credit_Amount", Voucher.Amount1, "@type", "Cr", "@Invoice_Date", Convert.ToDateTime(Voucher.InvoiceDate)); dbobj.ExecProc(App_Start.DbOperations_LATEST.OprType.Insert, "ProCustomerLedgerEntry", ref obj, "@Voucher_ID", Voucher.VoucherID, "@Ledger_ID", Voucher.LedgerIDDr, "@Amount", Voucher.Amount2, "@Type", "Dr.", "@Invoice_Date", Convert.ToDateTime(Voucher.InvoiceDate)); dbobj.ExecProc(App_Start.DbOperations_LATEST.OprType.Insert, "ProCustomerLedgerEntry", ref obj, "@Voucher_ID", Voucher.VoucherID, "@Ledger_ID", Voucher.LedgerIDDr, "@Amount", Voucher.Amount1, "@Type", "Cr.", "@Invoice_Date", Convert.ToDateTime(Voucher.InvoiceDate)); return(Created(new Uri(Request.RequestUri + ""), "Voucher Created")); }
public VoucherModel DeleteVoucher(int id) { VoucherModel voucher = db.VoucherModelRepository.GetByID(id); if (voucher == null) { return(null); } db.VoucherModelRepository.Delete(id); db.Save(); return(voucher); }
public void CalculateBasketTotalWithoutVoucher() { //setUp VoucherModel _voucher = new VoucherModel(); List <ProductModel> _productList = new List <ProductModel>(); _productList.Add(new ProductModel() { id = Guid.NewGuid(), description = "Green Apple", price = 2, type = Enumeration.ProductTypes.Apples }); _productList.Add(new ProductModel() { id = Guid.NewGuid(), description = "Green Apple", price = 2, type = Enumeration.ProductTypes.Apples }); _productList.Add(new ProductModel() { id = Guid.NewGuid(), description = "Green Apple", price = 2, type = Enumeration.ProductTypes.Apples }); _productList.Add(new ProductModel() { id = Guid.NewGuid(), description = "Orange", price = 2, type = Enumeration.ProductTypes.Oranges }); _productList.Add(new ProductModel() { id = Guid.NewGuid(), description = "Orange", price = 2, type = Enumeration.ProductTypes.Oranges }); using (var container = BuildIOCContainer()) { var basket = container.GetService <IBasket>(); //Action var basketModel = basket.CalculateBasketTotal(_productList, null); //asserts Assert.AreEqual(10, basketModel.totalPrice, "Totals do not match!"); } }
/// <summary> /// validate csv row /// </summary> /// <returns></returns> public Tuple <bool, List <string>, VoucherModel> CsvRowValidate(string rowItem) { var voucher = rowItem.Split(',').ToArray(); bool isError = false; VoucherModel voucherViewModel = new VoucherModel(); List <string> errorMassage = new List <string>(); try { if (string.IsNullOrEmpty(voucher[1])) { isError = true; errorMassage.Add("FullName Required"); } if (string.IsNullOrEmpty(voucher[7])) { isError = true; errorMassage.Add("VoucherValue Required"); } if (!Utilities.IsValidDatetime(voucher[6])) { isError = true; errorMassage.Add("Expiry Date is not in Right Format"); } if (!isError) { #region Testing Data // for testing // voucherViewModel.Token = "130E3452920015FEB7EE83AD7B1E80850495C4A0DDA137498E39783DC7355453"; voucherViewModel.CampaignId = 46; voucherViewModel.FirstName = voucher[15]; voucherViewModel.LastName = voucher[16]; voucherViewModel.FullName = voucher[0]; voucherViewModel.Expirydate = Convert.ToDateTime(voucher[6]); //System.DateTime.Now;//Convert.ToDateTime(voucher[6]); voucherViewModel.VoucherAmount = Decimal.Parse(voucher[7]); // same voucherViewModel.VoucherValue = Decimal.Parse(voucher[7]); // same voucherViewModel.Status = "Approved"; voucherViewModel.Email =; voucherViewModel.IsEmailToSend = true; voucherViewModel.SendVoucherAsPdf = true; voucherViewModel.IssueDate = System.DateTime.Now; //Convert.ToDateTime(voucher[5]); voucherViewModel.UseDate = System.DateTime.Now; //Convert.ToDateTime(voucher[12]); #endregion } } catch (Exception ex) { } return(Tuple.Create(isError, errorMassage, voucherViewModel)); }
public IHttpActionResult DeleteVoucherModel(int id) { VoucherModel voucherModel = db.VoucherRepository.GetByID(id); if (voucherModel == null) { return(NotFound()); } db.VoucherRepository.Delete(id); db.Save(); return(Ok(voucherModel)); }
public IActionResult AddVoucher(VoucherModel model) { if (!String.IsNullOrEmpty(model.Voucher)) { if (_shoppingCartProvider.ValidateVoucher(GetCartSummary(), model.Voucher, GetUserSession().UserID)) { return(RedirectToAction(nameof(Index))); } } TempData["VoucherError"] = Languages.LanguageStrings.VoucherInvalid; return(RedirectToAction(nameof(Index))); }
public IHttpActionResult PutVoucherModel(int id, VoucherModel voucherModel) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} //if (id != voucherModel.id) //{ // return BadRequest(); //} //voucherService.UpdateVoucher(id, voucherModel); //return StatusCode(HttpStatusCode.NoContent); if (!ModelState.IsValid || voucherModel.offerId == null || voucherModel.userId == null) { return(BadRequest(ModelState)); } if (id != voucherModel.id) { return(BadRequest()); } OfferModel offer = offerService.GetOffer((int)voucherModel.offerId); UserModel buyer = userService.GetUser((int)voucherModel.userId); if (offer == null || buyer == null) { return(NotFound()); } if (buyer.user_role != UserModel.UserRoles.ROLE_CUSTOMER) { return(BadRequest("User's role must be ROLE_CUSTOMER")); } voucherModel.offerModel = offer; voucherModel.userModel = buyer; VoucherModel updatedVoucher = voucherService.UpdateVoucher(id, voucherModel); if (updatedVoucher == null) { return(NotFound()); } return(Ok(updatedVoucher)); }
// TODO: Proper Voucher Detail linkage private async void OnTapped_Voucher(object sender, EventArgs e) { var args = (TappedEventArgs)e; var item = args.Parameter as FundraisingDetailItem; var voucherDetails = new VoucherModel { Description = item.Description, ID = item.ID, Image = item.Image, Name = item.Name, ValidUntilDate = item.ValidTill }; await Navigation.PushAsync(new VoucherViews.VoucherDetailsPage(item.ID, 0)); }
public VoucherModel CreateVoucherAfterBillPayment(BillModel bill) { VoucherModel voucher = new VoucherModel() { offerId = bill.offerId, userId = bill.userId, isUsed = false, expirationDate = DateTime.UtcNow.AddDays(7) }; db.VouchersRepository.Insert(voucher); db.Save(); return(voucher); }
public IHttpActionResult CustomerUpdate(VoucherModel Voucher) { SqlDataReader rdr = null; object obj1 = null; dbobj.ExecProc(DbOperations_LATEST.OprType.Insert, "UpdateAccountsLedgerForCustomer", ref obj1, "@Ledger_ID", Voucher.LedgerID, "@Invoice_Date", Voucher.InvoiceDate); dbobj.SelectQuery("select cust_id from customer,ledger_master where ledger_name=cust_name and ledger_id='" + Voucher.LedgerID + "'", ref rdr); if (rdr.Read()) { string strDate = GenUtil.str2DDMMYYYY(Voucher.InvoiceDate).Trim(); DateTime dtInvoice_Date = System.Convert.ToDateTime(strDate.ToString()); dbobj.ExecProc(DbOperations_LATEST.OprType.Insert, "UpdateCustomerLedgerForCustomer", ref obj1, "@Cust_ID", rdr["Cust_ID"].ToString(), "@Invoice_Date", dtInvoice_Date); } rdr.Close(); return(Created(new Uri(Request.RequestUri + ""), "CustomerUpdate")); }
public IHttpActionResult CustomerInsertUpdate(VoucherModel Voucher) { SqlDataReader rdr = null; InventoryClass obj = new InventoryClass(); SqlConnection Con = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["Servosms"]); object obj1 = null; dbobj.ExecProc(DbOperations_LATEST.OprType.Insert, "UpdateAccountsLedgerForCustomer", ref obj1, "@Ledger_ID", Voucher.LedgerID, "@Invoice_Date", System.Convert.ToDateTime(GenUtil.str2DDMMYYYY(Voucher.InvoiceDate))); dbobj.SelectQuery("select cust_id from customer,ledger_master where ledger_name=cust_name and ledger_id='" + Voucher.LedgerID + "'", ref rdr); if (rdr.Read()) { dbobj.ExecProc(DbOperations_LATEST.OprType.Insert, "UpdateCustomerLedgerForCustomer", ref obj1, "@Cust_ID", rdr["Cust_ID"].ToString(), "@Invoice_Date", System.Convert.ToDateTime(GenUtil.str2DDMMYYYY(Voucher.InvoiceDate))); } rdr.Close(); return(Created(new Uri(Request.RequestUri + ""), "CustomerInsertUpdate")); }
public VoucherModel PutVoucher(int id, VoucherModel voucher) { VoucherModel updateVoucher = db.VoucherModelRepository.GetByID(id); if (updateVoucher != null) { updateVoucher.ExpirationDate = voucher.ExpirationDate; updateVoucher.IsUsed = voucher.IsUsed; updateVoucher.Offer = voucher.Offer; updateVoucher.User = voucher.User; db.VoucherModelRepository.Update(updateVoucher); db.Save(); } return(updateVoucher); }
public IHttpActionResult PutVoucherModel(int id, VoucherModel voucherModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != voucherModel.id) { return(BadRequest()); } db.VoucherRepository.Update(voucherModel); db.Save(); return(StatusCode(HttpStatusCode.NoContent)); }