public async Task <ActionResult> checkdiscountcod(string dicode) { long cusid = 0; if (Request.Cookies.AllKeys.Contains("customerId")) { cusid = Convert.ToInt64(CreatHash.Decrypt(Request.Cookies["customerId"].Value)); Customer customerinfo = db.Customer.Where(p => p.Id == cusid).FirstOrDefault(); } else { return(new HttpStatusCodeResult(508)); } discountcode _discountcode = db.discountcode.Where(p => p.dicountcode == dicode).FirstOrDefault(); if (_discountcode == null) { return(new HttpStatusCodeResult(506)); } DateTime dateend = _discountcode.dateende; DateTime datenow = DateTime.Now; if (datenow > dateend) { return(new HttpStatusCodeResult(507)); } if (_discountcode.numberofuseg == 0 || _discountcode.numberofuseg == null) { _discountcode.numberofuseg = 1; _discountcode.customerid = cusid; await db.SaveChangesAsync(); List <CustomerProduct> customerProducts = db.CustomerProduct.Where(p => p.CustomerId == cusid && p.IdState == 1).ToList(); foreach (var item in customerProducts) { factor factor = db.factor.Where(p => p.factorcode == item.factorcod).FirstOrDefault(); factor.discountcode = _discountcode.dicountcode; factor.discountpercent = _discountcode.discountpersent; } await db.SaveChangesAsync(); } else if (_discountcode.numberofuseg >= 1) { return(new HttpStatusCodeResult(509)); } return(Json(_discountcode.discountpersent, JsonRequestBehavior.AllowGet)); }
static void Main(string[] args) { factor[] object_array = new factor[TESTOBJECTAMOUNT]; Initialize_Objects(object_array); Test_Factor_Comparison(object_array); Test_Reset(object_array); Console.WriteLine("Press enter to end program..."); Console.ReadLine(); }
public range(uint initial_val1 = 2, uint initial_val2 = 3) { factorObj1 = new factor(initial_val1); factorObj2 = new factor(initial_val2); max = 0; min = DEFAULTMIN; mean = 0; sum_of_pings = 0; num_of_pings = 0; }
private void picfactor_Click(object sender, EventArgs e) { Application.DoEvents(); action = "factor"; pnlfactor.BackColor = Color.FromArgb(24, 136, 146); pnlproduct.BackColor = Color.FromArgb(51, 51, 51); pnlstore.BackColor = Color.FromArgb(51, 51, 51); pnlnewfactor.BackColor = Color.FromArgb(51, 51, 51); factor p1 = new factor(); myLibrary.Currentfactor = p1; pnlparent.Controls.Clear(); pnlparent.Controls.Add(p1); }
static void Main(string[] args) { //Anonymous method Console.WriteLine("Anonymous method"); factor fact3 = delegate(int j) { for (int i = 1; i <= 3; ++i) { j = j * i; Console.WriteLine(j); } }; //Pay attention to ; fact3(1); Console.WriteLine(); //Lambda expression Lambda_ex ndiv2 = ll => ll % 3 == 0; Console.WriteLine("Lambda expression "); for (int i = 1; i <= 10; i++) { if (ndiv2(i)) { Console.WriteLine(i); } } Console.WriteLine(); //Lambda statements Console.WriteLine("Lambda statements"); Lambda_factor fact = n => { int jj = 1; for (int i = 1; i <= n; i++) { jj = i * jj; } return(jj); }; Console.WriteLine("The factorial of 1 is " + fact(1)); Console.WriteLine("The factorial of 3 is " + fact(3)); Console.WriteLine("Press any key to continue"); Console.ReadLine(); }
//PRE: Add will work properly if factor_value is a positive number greater than 0 and the object is active. //POST: May add a factor object to the array, increase the index of the array, and // may also set the array status to full. public void Add(uint factor_value) { if (isActive()) { if (factor_value == 0) { return; } if (index < max_array_size) { factor_objArray[index] = new factor(factor_value); index++; if (index == max_array_size) { full = true; } } } }
static void Initialize_Objects(factor[] object_array) { Console.WriteLine("Initializing an array of 20 factor objects"); Console.WriteLine(); uint random; for (int i = 0; i < TESTOBJECTAMOUNT; i++) { random = (uint)rand.Next(2, 30); if (i <= 4) { object_array[i] = new factor(); Console.WriteLine("Factor value of object " + (i + 1) + " is: " + DEFAULTFACTOR); } else { object_array[i] = new factor((int)random); Console.WriteLine("Factor value of object " + (i + 1) + " is: " + random); } } Console.WriteLine(); }
static void Main(string[] args) { Console.WriteLine("Enter your choice"); int options = Convert.ToInt32(Console.ReadLine()); switch (options) { case 1: Replace aclass = new Replace(); aclass.replace(); break; case 2: coinToss bclass = new coinToss(); bclass.coins(); break; case 3: leapYear cclass = new leapYear(); cclass.leap(); break; case 4: powerTwo dclass = new powerTwo(); dclass.power(); break; case 5: factor eclass = new factor(); eclass.primes(); break; case 6: Harmonic fclass = new Harmonic(); fclass.harnum(); break; case 7: Distance gclass = new Distance(); gclass.dist(); break; case 8: windchill hclass = new windchill(); hclass.wind(); break; case 9: quadricEquation iclass = new quadricEquation(); iclass.equation(); break; case 10: sumOfThree jclass = new sumOfThree(); jclass.integer(); break; case 11: Gambler kclass = new Gambler(); kclass.Game(); break; case 12: swatch lclass = new swatch(); lclass.watch(); break; case 13: coupon mclass = new coupon(); mclass.number(); break; case 14: TwoDArray nclass = new TwoDArray(); nclass.array2D(); break; case 15: TIC_TAC_TOE oclass = new TIC_TAC_TOE(); oclass.tok(); break; } }
SetWholeFactorIntervalAndSeconds(factor, interval, MidpointRounding.AwayFromZero);
public async Task <ActionResult> registercustomerproduct(itemcart _prop, string discontcode, long?_toltalprice) { List <CustomerProduct> _customerproduct = new List <CustomerProduct>(); CustomerProduct _cp = null; long cusid = 0; if (Request.Cookies.AllKeys.Contains("customerId")) { cusid = Convert.ToInt64(CreatHash.Decrypt(Request.Cookies["customerId"].Value)); Customer customerinfo = db.Customer.Where(p => p.Id == cusid).FirstOrDefault(); if (customerinfo.Mobile == "" || customerinfo.Mobile == null || customerinfo.Address == "" || customerinfo.Address == null) { return(new HttpStatusCodeResult(504)); } } else { return(new HttpStatusCodeResult(501)); } Random r = new Random(); string factorcode = ""; for (int i = 0; i < _prop.ListProps.Count(); i++) { long prid = _prop.ListProps[i].Id; #region deletecookie HttpCookie cookie = Request.Cookies["ProductBasketCookie"]; cookie.Expires = DateTime.Now.AddDays(-11); Response.Cookies.Add(cookie); #endregion factorcode = _prop.ListProps[i].Id + r.Next(1, 999999999).ToString() + r.Next(1, 999999999).ToString(); long _prices; var _price = db.ProductProperty.Where(p => p.IdProduct == prid && p.IdProperty == 4).FirstOrDefault().Value; _prices = Convert.ToInt64(_price); _cp = new CustomerProduct(); _cp.Count = _prop.ListProps[i].Value; _cp.CustomerId = cusid; _cp.DateRequest = DateTime.Now; _cp.IdState = 1; _cp.ProductId = _prop.ListProps[i].Id; _cp.StateDelete = false; if (discontcode != null && discontcode != "") { var discountpercent = db.discountcode.Where(p => p.dicountcode == discontcode).FirstOrDefault().discountpersent; var totalprice = _prices - (_prices * discountpercent); _cp.TotalPrice = _prop.ListProps[i].Value * totalprice; _toltalprice = 0; _toltalprice += _cp.TotalPrice; } else { _cp.TotalPrice = _prop.ListProps[i].Value * _prices; _toltalprice = 0; _toltalprice += _cp.TotalPrice; } _cp.factorcod = factorcode; _customerproduct.Add(_cp); } factor _f = new factor(); _f.customerId = cusid; _f.dateinsert = DateTime.Now; _f.discountcode = discontcode; if (discontcode != null && discontcode != "") { _f.discountpercent = db.discountcode.Where(p => p.dicountcode == discontcode).FirstOrDefault().discountpersent; } else { _f.discountpercent = null; } _f.factorcode = factorcode; _f.prcount = _customerproduct.Count(); _f.statedelete = false; _f.totalprice = (long)_toltalprice; db.factor.Add(_f); db.CustomerProduct.AddRange(_customerproduct); await db.SaveChangesAsync(); return(Json("ok", JsonRequestBehavior.AllowGet)); }
public static void Main(string[] args) { /*TEST STUFF Console.WriteLine("Hello World!"); * factor speed = new factor();; * speed.rating = 3; * speed.name = "fad"; * speed.multiplier =1; * Console.Write(nameof(factor)+" "+speed._rating+" "+speed.multiplier); * TEST STUFF*/ int factornumber = -1; factor[] arr = new factor[(int)numberOfFactors]; // fill attributes here and update numberOFFactors arr[++factornumber] = new factor("My company is quick to detect changes in its environment.", m: 0.1940657578 / 3); arr[++factornumber] = new factor("My company is quick to detect opportunities in its environment.", m: 0.1940657578 / 3); arr[++factornumber] = new factor("My company is quick to detect threats in its environment.", m: 0.1940657578 / 3); arr[++factornumber] = new factor("Our suppliers are quick to share relevant information with us.", m: 0.1828388132 / 3); arr[++factornumber] = new factor("Our customers are quick to share relevant information with us.", m: 0.1828388132 / 3); arr[++factornumber] = new factor("Usually, we can quickly access the data we need to make decisions.", m: 0.1828388132 / 3); arr[++factornumber] = new factor("My company has processes in place that allow for quick decision making.", m: 0.2173215718 / 3); arr[++factornumber] = new factor("My company is fast at making decisions regarding supply chain operations.", m: 0.2173215718 / 3); arr[++factornumber] = new factor("My company is fast at making decisions regarding supply chain tactics.", m: 0.2173215718 / 3); arr[++factornumber] = new factor("When it makes decisions regarding a change in its supply chain operations,my company can quickly implement it.", m: 0.2068965517 / 3); arr[++factornumber] = new factor("When it makes decisions regarding a change in its supply chain tactics,my company can quickly implement it.", m: 0.2068965517 / 3); arr[++factornumber] = new factor("my company is quick at implementing changes to its supply chain.", m: 0.2068965517 / 3); arr[++factornumber] = new factor("My company's suppliers can quickly meet an increase in order size.", m: 0.1988773055 / 3); arr[++factornumber] = new factor("My company's suppliers can quickly adjust the specification of orders.", m: 0.1988773055 / 3); arr[++factornumber] = new factor("My company's suppliers can quickly adjust/expedite their delivery lead time.", m: 0.1988773055 / 3); /* foreach(factor a in arr) //for test right now * { * Console.WriteLine(a.name+" "+a._rating+" "+a.multiplier); * } */ Console.Clear(); Console.Title = ("Supply Chain Agility Calculator"); string s = "***SUPPLY CHAIN AGILITY CALCULATOR***\n"; Console.SetCursorPosition((Console.WindowWidth - s.Length) / 2, Console.CursorTop); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine(s); Console.ResetColor(); for (int i = 0; i < numberOfFactors; i++) { Console.Write(arr[i].name + "(Rate Out of 10): "); arr[i].rating = Convert.ToInt16(Console.ReadLine()); Console.WriteLine(""); } decimal score = 0; foreach (factor a in arr) { score += (decimal)(a._rating * a.multiplier); } Console.BackgroundColor = ConsoleColor.Cyan; //Console.ForegroundColor = ConsoleColor.Red; Console.Write("Your Agility Score is " + score); Console.ResetColor(); Console.ReadKey(); Console.WriteLine(""); }