public OperationResult Define(DefineCustomerDiscount command) { var operation = new OperationResult(); if (_customerDiscountRepository == null) { operation.Failed(ApplicationMessages.RecordNotFound); } if (_customerDiscountRepository.Exist(x => x.ProductId == command.ProductId && x.DiscountRate == command.DiscountRate)) { return(operation.Failed(ApplicationMessages.DuplicatedRecord)); } var startDate = command.StartDate.ToGeorgianDateTime(); var endDate = command.EndDate.ToGeorgianDateTime(); var customerDiscount = new CustomerDiscount(command.ProductId, command.DiscountRate, startDate, endDate, command.DiscountReason); _customerDiscountRepository.Create(customerDiscount); _customerDiscountRepository.SaveChanges(); return(operation.Succedded()); }
public ActionResult Create(CustomerDiscountViewModel model) { if (ModelState.IsValid) { var CustomerDiscount = new CustomerDiscount(); AutoMapper.Mapper.Map(model, CustomerDiscount); CustomerDiscount.IsDeleted = false; CustomerDiscount.IsActive = true; CustomerDiscount.CreatedUserId = WebSecurity.CurrentUserId; CustomerDiscount.ModifiedUserId = WebSecurity.CurrentUserId; CustomerDiscount.AssignedUserId = WebSecurity.CurrentUserId; CustomerDiscount.CreatedDate = DateTime.Now; CustomerDiscount.ModifiedDate = DateTime.Now; CustomerDiscountRepository.InsertCustomerDiscount(CustomerDiscount); if (Request["IsPopup"] == "true") { ViewBag.closePopup = "close and append to page parent"; model.Name = model.Name; model.Id = CustomerDiscount.Id; return(View(model)); } TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess; return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult NewDiscount(int id, CustomerDiscount item) { if (!ModelState.IsValid) { return(PartialView("_NewDiscount", item)); } item.Discount /= 100m; if (item.Discount > 1) { item.Discount = 1; } else if (item.Discount < 0) { item.Discount = 0; } using (var scope = new TransactionScope()) { item.Customer = Customer.Find(id); item.Product = Product.Find(item.ProductId); item.CreateAndFlush(); } return(PartialView("_DiscountsRefresh")); }
public Task <CustomerDiscount> SaveAsync(CustomerDiscount CustomerDiscount, CancellationToken token = default(CancellationToken)) { #region merge query var query = @" MERGE INTO CustomerDiscount AS Cd USING ( SELECT @CustomerId AS CustomerId ) AS Target ON ( Cd.CustomerId = @CustomerId AND Cd.Sequence = @Sequence ) WHEN MATCHED THEN UPDATE SET CustomerId = @CustomerId, Sequence = @Sequence, Rate = @Rate, RoundingMode = @RoundingMode, MinValue = @MinValue, DepartmentId = @DepartmentId, AccountTitleId = @AccountTitleId, SubCode = @SubCode, UpdateBy = @UpdateBy, UpdateAt = GETDATE() WHEN NOT MATCHED THEN INSERT (CustomerId ,Sequence ,Rate ,RoundingMode ,MinValue ,DepartmentId ,AccountTitleId ,SubCode ,CreateBy ,CreateAt ,UpdateBy ,UpdateAt ) VALUES (@CustomerId ,@Sequence ,@Rate ,@RoundingMode ,@MinValue ,@DepartmentId ,@AccountTitleId ,@SubCode ,@CreateBy ,GETDATE() ,@UpdateBy ,GETDATE() ) OUTPUT inserted.*;"; #endregion return(dbHelper.ExecuteAsync <CustomerDiscount>(query, CustomerDiscount, token)); }
public Task <int> DeleteAsync(CustomerDiscount discount, CancellationToken token = default(CancellationToken)) { var query = @" DELETE CustomerDiscount WHERE CompanyId = @CompanyId"; if (discount.Sequence > 0) { query += @" AND [Sequence] = @Sequence"; } return(dbHelper.ExecuteAsync(query, discount, token)); }
public OperationResult Define(DefineCustomerDiscount command) { OperationResult operationResult = new OperationResult(); var std = command.StartDate.ToGeorgianDateTime(); var Etd = command.EndDate.ToGeorgianDateTime(); var CustomerDiscount = new CustomerDiscount(command.ProductId, command.DiscountRate, std, Etd, command.Reason); _coustomerDiscountRepo.Create(CustomerDiscount); _coustomerDiscountRepo.Save(); return(operationResult.Succeeded()); }
public ActionResult RemoveDiscount(int id) { var entity = CustomerDiscount.Find(id); if (entity == null) { Response.StatusCode = 400; return(Content(Resources.ItemNotFound)); } using (var scope = new TransactionScope()) { entity.DeleteAndFlush(); } return(Json(new { id = id, result = true })); }
public OperationResult Define(DefineCustomerDiscount command) { var operationResult = new OperationResult(); if (_customerDiscountRepository.Exists(cd => cd.ProductId == command.ProductId && cd.Reason == command.Reason && cd.DiscountRate == command.DiscountRate)) { return(operationResult.Failed(QueryValidationMessage.DuplicateRecord)); } var customerDiscount = new CustomerDiscount(command.ProductId, command.DiscountRate, command.Reason, command.StartDate.ToGeorgianDateTime(), command.EndDate.ToGeorgianDateTime()); _customerDiscountRepository.Create(customerDiscount); _customerDiscountRepository.SaveChanges(); return(operationResult.Succeeded()); }
public OperationResult Define(CustomerDiscountDefine create) { var operation = new OperationResult(); if (_customerDiscountRepository.Exists(d => d.ProductId == create.ProductId && d.DiscountRate == create.DiscountRate)) { return(operation.Fail(ApplicationMessages.DuplicateRecord)); } var dateStart = create.DateStart.ToGeorgianDateTime(); var dateEnd = create.DateEnd.ToGeorgianDateTime(); var customerDiscount = new CustomerDiscount(create.ProductId, create.DiscountRate, dateStart, dateEnd, create.Reason); _customerDiscountRepository.Create(customerDiscount); _customerDiscountRepository.SaveChanges(); return(operation.Success()); }
private decimal CalculateDiscount() { CustomerDiscount _customerDiscount; if (_customerOrder._customerStatus == CustomerStatus.Gold) { _customerDiscount = new CustomerDiscount(new CustomerGoldDiscount()); return _customerDiscount.GetDiscount(_productOrder._quantity); } else if (_customerOrder._customerStatus == CustomerStatus.Silver) { _customerDiscount = new CustomerDiscount(new CustomerSilverDiscount()); return _customerDiscount.GetDiscount(_productOrder._quantity); } else if (_customerOrder._customerStatus == CustomerStatus.Bronze) { _customerDiscount = new CustomerDiscount(new CustomerBrownDiscount()); return _customerDiscount.GetDiscount(_productOrder._quantity); } return 0m; }
protected override OpResult _Store(CustomerDiscount _obj) { if (_obj == null) { return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "CustomerDiscount object cannot be created as it is null")); } if (Exists(_obj)) { ExecuteNonQuery(GetQuery_UpdateQuery(_obj)); return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj)); } ExecuteNonQuery(GetQuery_InsertQuery(_obj)); if (_obj.CustomerDiscountID == null) { _obj.CustomerDiscountID = DbMgr.GetLastInsertID(); } _obj.FromDb = true; return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj)); }
public ActionResult SetDiscount(int id, string value) { var entity = CustomerDiscount.Find(id); bool success; decimal val; success = decimal.TryParse(value.TrimEnd(new char [] { ' ', '%' }), out val); val /= 100m; if (success && val >= 0 && val <= 1) { entity.Discount = val; using (var scope = new TransactionScope()) { entity.UpdateAndFlush(); } } return(Json(new { id = entity.Id, value = entity.FormattedValueFor(x => x.Discount) })); }
public async Task <CustomerDiscount> SaveAsync(CustomerDiscount CustomerDiscount, CancellationToken token = default(CancellationToken)) => await addCustomerDiscountQueryProcessor.SaveAsync(CustomerDiscount, token);
private DbUpdateStatement GetQuery_UpdateQuery(CustomerDiscount _obj) { return(DbMgr.CreateUpdateClause("CustomerDiscounts", GetFields(_obj), "CustomerDiscountID", _obj.CustomerDiscountID)); }
private DbInsertStatement GetQuery_InsertQuery(CustomerDiscount _obj) { Dictionary <string, DbFieldEntry> fields = GetFields(_obj); return(DbMgr.CreateInsertClause("CustomerDiscounts", fields)); }
public ActionResult NewDiscount(int id, CustomerDiscount item) { if (!ModelState.IsValid) { return PartialView ("_NewDiscount", item); } item.Discount /= 100m; if (item.Discount > 1) { item.Discount = 1; } else if (item.Discount < 0) { item.Discount = 0; } using (var scope = new TransactionScope ()) { item.Customer = Customer.Find (id); item.Product = Product.Find (item.ProductId); item.CreateAndFlush (); } return PartialView ("_DiscountsRefresh"); }
public async Task <ActionResult <int> > DeleteDiscount(CustomerDiscount discount, CancellationToken token) => await customerDiscountProcessor.DeleteAsync(discount, token);
public async Task <ActionResult <CustomerDiscount> > SaveDiscount(CustomerDiscount customerDiscount, CancellationToken token) => await customerDiscountProcessor.SaveAsync(customerDiscount, token);
protected void btnGetRecords_Click(object sender, EventArgs e) { try { string Customer = txtcustomer.Text.Trim(); customrcode = Customer.Split(':')[0].ToString(); DataTable dt = new DataTable(); dt = DCMaster.Get_Name(customrcode, "Customer").Tables[0]; if (dt.Rows.Count > 0) { lblCustomerName.Text = dt.Rows[0]["CustName"].ToString(); lblCustID.Text = dt.Rows[0]["CustID"].ToString(); } else { lblCustomerName.Text = "No such customer found"; } DataSet ds1 = new DataSet(); ds = helpdesk.getAllHelpDesk(customrcode, strFY); //ds1 = Customer_cs.Idv_Chetana_Customer_BlackList(0,customrcode,"31-mar-"+DateTime.Now.Year.ToString(),0,1,2,0); RepCustomerDetails.DataSource = ds.Tables[0]; RepCustomerDetails.DataBind(); REpChetanaForcust.DataSource = ds.Tables[1]; REpChetanaForcust.DataBind(); RepChLstOrder.DataSource = ds.Tables[2]; RepChLstOrder.DataBind(); RepPayment.DataSource = ds.Tables[3]; RepPayment.DataBind(); RepPendingDC.DataSource = ds.Tables[5]; RepPendingDC.DataBind(); CustomerDiscount.DataSource = ds.Tables[6]; CustomerDiscount.DataBind(); rptConfirmed.DataSource = ds.Tables[7]; rptConfirmed.DataBind(); rptPOD.DataSource = ds.Tables[8]; rptPOD.DataBind(); if (CustomerDiscount.Items.Count > 0) { lblDiscMsg.Visible = false; } else { lblDiscMsg.Visible = true; } if (RepPendingDC.Items.Count > 0) { lnkMoreDc.Visible = true; LnkBtn.Visible = true; } else { lnkMoreDc.Visible = false; LnkBtn.Visible = false; } // int custId = 0; // if (ds.Tables[0].Rows.Count > 0) // { // custId = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString()); //} //ds1 = Customer_cs.Idv_Chetana_Customer_BlackList(custId, "HLPDSK", "31-mar-" + DateTime.Now.Year.ToString(), 0, Convert.ToInt32(strFY), 2, 0); //RepOutStanding.DataSource = ds1.Tables[0]; //RepOutStanding.DataBind(); } catch (Exception ex) { } }
public async Task <CustomerDiscountResult> SaveDiscountAsync(string SessionKey, CustomerDiscount CustomerDiscount) { return(await authorizationProcessor.DoAuthorizeAsync(SessionKey, async token => { var result = await customerDiscountProcessor.SaveAsync(CustomerDiscount, token); return new CustomerDiscountResult { ProcessResult = new ProcessResult { Result = true }, CustomerDiscount = result, }; }, logger)); }
public async Task <int> DeleteAsync(CustomerDiscount discount, CancellationToken token = default(CancellationToken)) => await deleteCustomerDiscountQueryProcessor.DeleteAsync(discount, token);