public async Task <IActionResult> PutUserinfo([FromRoute] int id, [FromBody] Userinfo userinfo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != userinfo.Id) { return(BadRequest()); } _context.Entry(userinfo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserinfoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult CourseAssignToTeacher(CourseAssign courseAssign) { var course = db.Courses.FirstOrDefault(x => x.CourseId == courseAssign.CourseId); course.TeacherId = courseAssign.TeacherId; db.Entry(course).State = EntityState.Modified; courseAssign.Status = "Assigned"; db.Entry(courseAssign).State = EntityState.Added; db.SaveChanges(); return(RedirectToAction("Index", "CourseAssign")); }
public async Task <IActionResult> PutAffectation(int id, Affectation affectation) { if (id != affectation.AffectationId) { return(BadRequest()); } _context.Entry(affectation).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AffectationExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutConsultant(int id, Consultant consultant) { if (id != consultant.consultantId) { return(BadRequest()); } _context.Entry(consultant).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ConsultantExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "Id,Name,Price,Quantity,PetRelated,Description")] Product product) { if (ModelState.IsValid) { if (product.Price < 0 || product.Price == 0) { ViewBag.ErrMsg = "The price need to be bigger then ziro"; } else if (product.Quantity < 0) { ViewBag.ErrMsg = "The quantity need to be positive number"; } else { product.Name = product.Name.ToUpper(); if (product.Description != null) { product.Description = product.Description.ToLower(); } db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(product)); }
public async Task <IActionResult> PutPrices([FromRoute] int id, [FromBody] Prices prices) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != prices.ProductId) { return(BadRequest()); } _context.Entry(prices).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PricesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "Id,IsOpen,Pet_Id,User_Id")] AdoptionRequest adoptionRequest) { adoptionRequest.Pet = db.Pets.Find(adoptionRequest.Pet_Id); adoptionRequest.Pet_Id = db.Pets.Find(adoptionRequest.Pet_Id).Id; adoptionRequest.Pet.Organization_Id = db.Pets.Find(adoptionRequest.Pet_Id).Organization.Id; if (adoptionRequest.Pet.IsAdopted) { return(RedirectToAction("Index", "Error", new { message = "The pet is alredy adopted" })); } else { User sessionUser = (User)System.Web.HttpContext.Current.Session["user"]; adoptionRequest.User = db.Users.Find(adoptionRequest.User_Id); adoptionRequest.User_Id = db.Users.Find(adoptionRequest.User_Id).Id; var ar = from b in db.AdoptionRequests.Where(x => x.Pet_Id == adoptionRequest.Pet.Id) select b; foreach (AdoptionRequest item in ar) { if (item.User_Id == adoptionRequest.User.Id) { return(RedirectToAction("Index", "Error", new { message = "The adoption request for " + adoptionRequest.Pet.Name + " alredy exist for " + adoptionRequest.User.Username })); } } if (ModelState.IsValid) { adoptionRequest.IsOpen = true; db.Entry(adoptionRequest).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(adoptionRequest)); } if (ModelState.IsValid) { db.Entry(adoptionRequest).State = EntityState.Modified; db.Entry(adoptionRequest.Pet).State = EntityState.Modified; db.Entry(adoptionRequest.User).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(adoptionRequest)); }
public ActionResult Edit([Bind(Include = "ID,Title,StartDate,EndDate,PM,Resource,Notes")] Project project) { if (ModelState.IsValid) { db.Entry(project).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(project)); }
public ActionResult Edit([Bind(Include = "BedId,BedNo,BedType,Price")] Bed bed) { if (ModelState.IsValid) { db.Entry(bed).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bed)); }
public ActionResult Edit([Bind(Include = "MedicineId,MedicineName")] Medicine medicine) { if (ModelState.IsValid) { db.Entry(medicine).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(medicine)); }
public void UpdateCategory(Category category) { using (var context = new ProjectDBContext()) { //Update category context.Entry(category).State = System.Data.Entity.EntityState.Modified; //Save Changes context.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "DoctorSpecializationId,Specialization")] DoctorSpecialization doctorSpecialization) { if (ModelState.IsValid) { db.Entry(doctorSpecialization).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(doctorSpecialization)); }
public ActionResult Edit([Bind(Include = "NurseId,NationalID,Name,Address,Contact")] Nurse nurse) { if (ModelState.IsValid) { db.Entry(nurse).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nurse)); }
public void UpdateProduct(Product product) { using (var context = new ProjectDBContext()) { //Update Product context.Entry(product).State = System.Data.Entity.EntityState.Modified; //Save Changes context.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "DepartmentId,DepartmentCode,DepartmentName")] Department department) { if (ModelState.IsValid) { db.Entry(department).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(department)); }
public ActionResult Edit([Bind(Include = "SemesterId,SemesterNO")] Semester semester) { if (ModelState.IsValid) { db.Entry(semester).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(semester)); }
public ActionResult Edit([Bind(Include = "ID,Name,DueDate,StartDate")] Project project) { if (ModelState.IsValid) { db.Entry(project).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(project)); }
public ActionResult Edit([Bind(Include = "DesignationId,DesignationName")] Designation designation) { if (ModelState.IsValid) { db.Entry(designation).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(designation)); }
public ActionResult Edit([Bind(Include = "ID,Name,LiveLink,GitLink,GitLinkText,Designer")] Project project) { if (ModelState.IsValid) { db.Entry(project).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(project)); }
public ActionResult Edit([Bind(Include = "StudentId,StudentName,StudentEmail,StudentContactNo,Date,StudentAddress,StudentRegNo,DepartmentId")] Student student) { if (ModelState.IsValid) { db.Entry(student).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "DepartmentCode", student.DepartmentId); return(View(student)); }
public ActionResult Edit([Bind(Include = "ProjectID,Title,URL,DepartmentID")] Project project) { if (ModelState.IsValid) { db.Entry(project).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "DepartmentName", project.DepartmentID); return(View(project)); }
public ActionResult Edit([Bind(Include = "CourseId,Code,Credit,Name,Description,DepartmentId,SemesterId")] Course course) { if (ModelState.IsValid) { db.Entry(course).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DepartmentId = new SelectList(db.Department, "DepartmentId", "DepartmentCode", course.DepartmentId); ViewBag.SemesterId = new SelectList(db.Semester, "SemesterId", "SemesterId", course.SemesterId); return(View(course)); }
public ActionResult Edit([Bind(Include = "TeacherId,Name,Address,Email,ContactNo,DesignationId,DepartmentId,Credit,CreditTaken")] Teacher teacher) { if (ModelState.IsValid) { db.Entry(teacher).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DepartmentId = new SelectList(db.Department, "DepartmentId", "DepartmentCode", teacher.DepartmentId); ViewBag.DesignationId = new SelectList(db.Designation, "DesignationId", "DesignationName", teacher.DesignationId); return(View(teacher)); }
public ActionResult Edit([Bind(Include = "IndoorPatientId,Name,Age,Gender,BedId,Admissiondate,Releasedate,DoctorId")] IndoorPatient indoorPatient) { if (ModelState.IsValid) { db.Entry(indoorPatient).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BedId = new SelectList(db.Bed, "BedId", "BedNo", indoorPatient.BedId); ViewBag.DoctorId = new SelectList(db.Doctor, "DoctorId", "Name", indoorPatient.DoctorId); return(View(indoorPatient)); }
public ActionResult Edit([Bind(Include = "DoctorId,Name,Email,DoctorDepartmentId,Degree,DoctorSpecializationId,Phone")] Doctor doctor) { if (ModelState.IsValid) { db.Entry(doctor).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DoctorDepartmentId = new SelectList(db.DoctorDepartment, "DoctorDepartmentId", "DoctorDepartmentName", doctor.DoctorDepartmentId); ViewBag.DoctorSpecializationId = new SelectList(db.DoctorSpecialization, "DoctorSpecializationId", "Specialization", doctor.DoctorSpecializationId); return(View(doctor)); }
public ActionResult Edit([Bind(Include = "Id,Name,Age,IsAdopted,AnimalType,Description,Organization_Id")] Pet pet) { Organization organization = db.Organizations.Find(pet.Organization_Id); pet.Organization = organization; if (ModelState.IsValid) { db.Entry(pet).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pet)); }
public void SaveProduct(Product product) { using (var context = new ProjectDBContext()) { // jehetu akoi category bar bar notun kore create hoy tai ata unchange kore dite hobe context.Entry(product.Category).State = System.Data.Entity.EntityState.Unchanged; //Add Product context.Products.Add(product); //Save Changes context.SaveChanges(); } }
public async Task <IActionResult> SaveChange(User u) { try { db.Entry(u).State = EntityState.Modified; await db.SaveChangesAsync(); return(View(u.ID)); } catch (Exception e) { return(Content(e.Message)); } }
public async Task <IActionResult> UpdateProduct(Product prod) { try { db.Entry(prod).State = EntityState.Modified; await db.SaveChangesAsync(); MenuVM vm = new MenuVM(); vm.userID = prod.FarmerID; return(View(vm)); } catch (Exception e) { return(Content(e.Message)); } }
public async Task <IActionResult> Checkout(long id) { try { string key = "cart" + id.ToString(); var cacheEntryOptions = new MemoryCacheEntryOptions() .SetSlidingExpiration(TimeSpan.FromMinutes(10)); Dictionary <Product, int> cart; if (!_cache.TryGetValue(key, out cart)) { cart = new Dictionary <Product, int>(); _cache.Set(key, cart, cacheEntryOptions); } User buyer = await db.Users.FindAsync(id); List <Product> keyList = new List <Product>(cart.Keys); Purchase newPurchase; Sale newSale; foreach (Product p in keyList) { newPurchase = new Purchase(id, p.Name, cart[p]); db.PurchaseHistory.Add(newPurchase); await db.SaveChangesAsync(); newSale = new Sale(p.FarmerID, p.Name, cart[p], buyer.Address, buyer.Username); db.SalesHistory.Add(newSale); await db.SaveChangesAsync(); p.Stock -= cart[p]; db.Entry(p).State = EntityState.Modified; await db.SaveChangesAsync(); } cart = new Dictionary <Product, int>(); _cache.Set(key, cart, cacheEntryOptions); return(View(id)); } catch (Exception e) { return(Content(e.Message)); } }