public ActionResult DeleteConfirmed(long id) { tblVariety tblvariety = db.tblVarieties.Find(id); db.tblVarieties.Remove(tblvariety); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "varietyId,name,sampleNumber,repUser,testDate,releaseStatus,resistance,storability,poundability,species,uniformity,stability,distinctness,value,activityId,locationId,userId,createdBy,createdDate,updatedBy,updatedDate")] tblVariety tblvariety) { if (ModelState.IsValid) { db.Entry(tblvariety).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.activityId = new SelectList(db.tblActivities, "activityId", "name", tblvariety.activityId); return(View(tblvariety)); }
// GET: /Variety/Details/5 public ActionResult Details(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblVariety tblvariety = db.tblVarieties.Find(id); if (tblvariety == null) { return(HttpNotFound()); } return(View(tblvariety)); }
// GET: /Variety/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblVariety tblvariety = db.tblVarieties.Find(id); if (tblvariety == null) { return(HttpNotFound()); } ViewBag.activityId = new SelectList(db.tblActivities, "activityId", "name", tblvariety.activityId); return(View(tblvariety)); }
private void SyncIncomingRecords(ChileMaterialsReceived received, tblLot tblLot, ICollection <tblVariety> varieties) { foreach (var incoming in tblLot.tblIncomings.ToList()) { OldContext.tblIncomings.DeleteObject(incoming); } var treatment = OldContextHelper.GetTreatment(received); var varietyId = varieties.Select(v => v.VarietyID).DefaultIfEmpty(0).Max() + 1; foreach (var item in received.Items) { var packaging = OldContextHelper.GetPackaging(item.PackagingProduct); var variety = varieties.FirstOrDefault(v => v.Variety == item.ChileVariety); if (variety == null) { variety = new tblVariety { VarietyID = varietyId++, Variety = item.ChileVariety, EntryDate = DateTime.Now, InActive = false, SortOrder = varietyId.ToString() }; OldContextHelper.OldContext.tblVarieties.AddObject(variety); varieties.Add(variety); } tblLot.tblIncomings.Add(new tblIncoming { EmployeeID = tblLot.EmployeeID, EntryDate = tblLot.EntryDate.Value, TTypeID = (int?)(received.ChileMaterialsReceivedType == ChileMaterialsReceivedType.Dehydrated ? TransType.DeHy : TransType.Other), Quantity = item.Quantity, TrtmtID = treatment.TrtmtID, Tote = item.ToteKey, VarietyID = variety.VarietyID, Company_IA = tblLot.Company_IA, LocID = item.Location.LocID.Value, DehyLocale = item.GrowerCode, PkgID = packaging.PkgID, NetWgt = packaging.NetWgt, TtlWgt = item.Quantity * packaging.NetWgt }); } }