public ActionResult GetCropRotation(int fieldidfrommap, int year) { ViewBag.Language = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName; CropRotation CropRotation = db.CropRotations .Where(c => c.fieldgid == fieldidfrommap && c.Year == year) .FirstOrDefault(); string CropRotationTypeName = ""; CropRotationType CropRotationType = null; if(CropRotation != null) { CropRotationType = db.CropRotationTypes .Where(c => c.Id == CropRotation.CropRotationTypeId) .FirstOrDefault(); } if(CropRotationType != null) { if (ViewBag.Language == "ru") { CropRotationTypeName = CropRotationType.NameRU; } if (ViewBag.Language == "en") { CropRotationTypeName = CropRotationType.NameEN; } if (ViewBag.Language == "kk") { CropRotationTypeName = CropRotationType.NameKK; } } return Json(new { CropRotationTypeName = CropRotationTypeName }); }
public async Task <ActionResult> DeleteConfirmed(int id) { CropRotationType cropRotationType = await db.CropRotationTypes.FindAsync(id); db.CropRotationTypes.Remove(cropRotationType); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "Id,NameRU,NameKK,NameEN")] CropRotationType cropRotationType) { if (ModelState.IsValid) { db.Entry(cropRotationType).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(cropRotationType)); }
public async Task <ActionResult> Create([Bind(Include = "Id,NameRU,NameKK,NameEN")] CropRotationType cropRotationType) { if (ModelState.IsValid) { db.CropRotationTypes.Add(cropRotationType); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(cropRotationType)); }
public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CropRotationType cropRotationType = await db.CropRotationTypes.FindAsync(id); if (cropRotationType == null) { return(HttpNotFound()); } return(View(cropRotationType)); }