// Donate public async Task <IActionResult> Donate() { var user = HttpContext.User.Claims.FirstOrDefault(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"); var user_id = user.Value; var cart = _context.Cart.Where(c => c.UserId == user_id); if (String.IsNullOrEmpty(user_id)) { return(RedirectToAction("Index")); } else { foreach (var item in cart) { Donation donation = new Donation(); donation.Amount = item.Amount; donation.SpeciesId = item.SpeciesId; donation.UserId = item.UserId; _context.Add(donation); } _context.SaveChanges(); } RemoveFromCartByUser(user_id); // var donate = _context.Donation.Where(c => c.UserId == user_id); return(RedirectToAction("Index")); // View(await donate.ToListAsync()); }
public void CreateStudent(Student student) { using (var db = new EsDbContext()) { db.Students.Add(student); db.SaveChanges(); } }
public void CreateLoanInformation(LoanInformation loanInformation) { using (var db = new EsDbContext()) { db.LoanInformations.Add(loanInformation); db.SaveChanges(); } }
public void CreateComponentType(ComponentType componentType) { using (var db = new EsDbContext()) { db.ComponentTypes.Add(componentType); db.SaveChanges(); } }
public void CreateComponent(Component component) { using (var db = new EsDbContext()) { db.Components.Add(component); db.SaveChanges(); } }
public void DeleteStudent(int id) { using (var db = new EsDbContext()) { var student = db.Students.Find(id); db.Students.Remove(student); db.SaveChanges(); } }
public void DeleteLoanInformation(int id) { using (var db = new EsDbContext()) { var loanInformation = db.LoanInformations.Find(id); db.LoanInformations.Remove(loanInformation); db.SaveChanges(); } }
public void DeleteComponentType(int id) { using (var db = new EsDbContext()) { var componentType = db.ComponentTypes.Find(id); db.ComponentTypes.Remove(componentType); db.SaveChanges(); } }
public void RemoveFromCart(int id) { var cart = _context.Cart.SingleOrDefault(m => m.Id == id); _context.Cart.Remove(cart); _context.SaveChanges(); return; }
public void Update(EsDbContext context) { var category1 = new Category { CategoryName = "Cameras" }; context.Categories.Add(category1); var comType1 = new ComponentType { ComponentName = "Camera", CategoryId = category1.Id }; context.ComponentTypes.Add(comType1); var com1 = new Component { ComponentNumber = 14, ComponentTypeId = comType1.Id, SerieNr = "983234-EB", UserComment = "Great camera!", AdminComment = "Need to buy more of these", }; context.Components.Add(com1); var student1 = new Student { Email = "*****@*****.**", MobilNo = "88888888", StudentName = "Leasy", StudentId = "201012345", }; context.Students.Add(student1); var loan1 = new LoanInformation { IsReservation = false, LoanDate = DateTime.Now, StudentId = student1.Id, ReservationDate = DateTime.Now, ReturnDate = DateTime.Now.AddMonths(1) }; context.LoanInformations.Add(loan1); context.SaveChanges(); }
public void UpdateStudent(Student student) { using (var db = new EsDbContext()) { db.Entry(student).State = EntityState.Modified; db.SaveChanges(); } }
public void UpdateLoanInformation(LoanInformation loanInformation) { using (var db = new EsDbContext()) { db.Entry(loanInformation).State = EntityState.Modified; db.SaveChanges(); } }
public void UpdateComponentType(ComponentType componentType) { using (var db = new EsDbContext()) { db.Entry(componentType).State = EntityState.Modified; db.SaveChanges(); } }