[HttpPost] //[ValidateAntiForgeryToken] public ActionResult RemoveAdmin(string userid) { ApplicationUser au = context.Users.Where(u => u.Id.Equals(userid, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault(); var store = new UserStore<ApplicationUser>(context); var manager = new UserManager<ApplicationUser>(store); manager.RemoveFromRole(au.Id, "Admin"); manager.AddToRole(au.Id, "User"); if (Request.IsAjaxRequest()) { TempData["SuccessRole"] = "Role Removed Successfully"; Json(Url.Action("AssignAdmin")); return RedirectToAction("AssignAdmin", "SuperAdmin"); } //TempData["Success"] = "Roles Assigned Successfully"; return RedirectToAction("AssignAdmin"); } function clickMe() { var userid = $("#userAdmins").val(); if (userid != "") { $.ajax({ url: "RemoveAdmin/SuperAdmin", data: { userid: userid }, type: "POST", success: function (result) { window.location.assign(result); } //error: function () { // alert("Error"); //} });
public static void Countsolve(int amount, int[] arraycount) { int[] cash = { 100, 50, 20, 10, 5, 1 }; int[] bcounter = { 0, 0, 0, 0, 0, 0 }; for(int i = 0; i < 6; i++) { if(amount >= cash[i]) { counter[i] = amount / cash[i]; amount -= bcounter[i] * cash[i]; } } for(int x=0; x<arraycount.Length; x++) { arraycount[x] = arraycount[x] - bcounter[x]; }
public static void countbills(int amount, int[] bills, int[] billsCount) { int remainder = amount; int billIterator = 1; for(int i = 0; i < billsCount.Length; i++) // while(remainder > 0) { //if(remainder >= bills[billIterator]) //{ if(billsCount[]) } if (remainder >= bills[i]) { if (billsCount[i] != 0) { billsCount[i]--; remainder -= bills[billIterator];//bills[i] * billsCount[billIterator]; billIterator++; //= bills[i];//amount / bills[i]; //remainder -= counts[bill] * dollarSizes[bill]; //reminder = amount % cashBills[billrem]; //amount -= billsCount[i] * bills[i]; //billsCount[i]--; } } } }
public static int[] Reset( int[] billsRefill) { //int[] cashRefill = { 10, 10, 10, 10, 10, 10 }; foreach(int spot in billsRefill) { spot = 10; } return billsRefill; }
public static int[] MakeChange(int amount) { int[] cashBills = { 100, 50, 20, 10, 5, 1 }; int[] billCounts = { 0, 0, 0, 0, 0, 0 }; int billrem = 0; //bill=0 int reminder = amount; //remainder while(reminder > 0) { billCounts[billrem] = reminder / cashBills[billrem]; reminder = amount % cashBills[billrem]; billrem++; } return billCounts; }
HundredDollarBill = cash / 100; cash %= 100;
$("#back").click(function() { if (index < 0) { index = 0; } else { var first = arr[index]; $("#sec2").html('<h5>'+first.id+'</h5>'); index--; } });
$("#back").click(function() { //var s = arr[index]; var first = arr.first(); //$("#sec2").innerHTML(<span>first</span>); })
Application.Current.Dispatcher.Invoke(delegate 17 { 18 backgroundWorker.ReportProgress(); //but what do i pass in and not sure if this is it 19 });
public static int CreateReceipt(int userid, decimal rtotal, DateTime rdate) { int result = -1; using(SqlConnection connection = ConnectionString.GetSqlConnection()) { string sqlCreate = "INSERT INTO Orders(UserId, ReceiptDate, ReceiptTotal) " + "VALUES(@uid, @date, @rtotal)"; using(SqlCommand cmdCreate = new SqlCommand(sqlCreate, connection)) { //cmdCreate.Parameters.AddWithValue("@rid", receipt.ReceiptID); cmdCreate.Parameters.AddWithValue("@uid", userid); cmdCreate.Parameters.AddWithValue("@date", rdate); cmdCreate.Parameters.AddWithValue("rtotal", rtotal); try { connection.Open(); string sqlSELECT = "SELECT @@IDENTITY FROM Orders"; cmdCreate.ExecuteNonQuery(); SqlCommand cmdSelect = new SqlCommand(sqlSELECT, connection); result = Convert.ToInt32(cmdSelect.ExecuteScalar()); } catch(Exception ex) { throw ex; } } } return result; }
//no longer using my 4 seperate lists because all fields are in my product class. private List<Product> listOfP = new List<Product>(); public List<Product> Cart => new List<Product>(); public ShoppingCart(Customer c, List<Product> listprod) { InitializeComponent(); customer = c; listOfP = listprod; CreateCart(listOfP); PopulateListViewCart(); } private void CreateCart(List<Product> lcart) { //Cart.Add(selectedProduct); foreach(Product product in listOfP) { Cart.Add(product); } }