public async Task <IActionResult> Edit(long id, [Bind("ID,user,package_type,date,destination_city,Consignee_name,address,pkg_weight_in_grams,amount")] Consignment_Details consignment_Details) { if (id != consignment_Details.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(consignment_Details); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Consignment_DetailsExists(consignment_Details.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(consignment_Details)); }
public async Task <IActionResult> Create(String consignee_name, String city, String address, int pkg_weight_in_grams, String package_type, String package_content) { Consignment_Details details = new Consignment_Details(); details.date = DateTime.Now; details.Consignee_name = consignee_name; details.destination_city = city; details.address = address; details.package_type = package_type; details.pkg_weight_in_grams = pkg_weight_in_grams; cno++; details.consignment_no = cno; details.user = _accessor.HttpContext.Session.GetString("logged_in_user"); details.package_content = package_content; details.amount = 600.0F; Consignment_Status status = new Consignment_Status(); status.consignment_no = details.consignment_no; status.date = details.date; status.user = details.user; status.consignee_name = details.Consignee_name; Console.WriteLine("consignment id: " + details); if (ModelState.IsValid) { _context.Add(details); _context.Add(status); await _context.SaveChangesAsync(); return(Redirect("/User/Profile")); } else { return(Redirect("/User/Profile")); } }