Esempio n. 1
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,CropRotationTypeId,fieldgid,Year")] CropRotation cropRotation)
        {
            ViewBag.Language = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
            int field_count = db.fields.Where(f => f.gid == cropRotation.fieldgid).Count();

            if ((ModelState.IsValid) && (field_count > 0))
            {
                db.Entry(cropRotation).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            if (ViewBag.Language == "ru")
            {
                ViewBag.CropRotationTypeId = new SelectList(db.CropRotationTypes, "Id", "NameRU", cropRotation.CropRotationTypeId);
            }
            if (ViewBag.Language == "en")
            {
                ViewBag.CropRotationTypeId = new SelectList(db.CropRotationTypes, "Id", "NameEN", cropRotation.CropRotationTypeId);
            }
            if (ViewBag.Language == "kk")
            {
                ViewBag.CropRotationTypeId = new SelectList(db.CropRotationTypes, "Id", "NameKK", cropRotation.CropRotationTypeId);
            }
            return(View(cropRotation));
        }
Esempio n. 2
0
        public async Task <ActionResult> Edit(int?id)
        {
            ViewBag.Language = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CropRotation cropRotation = await db.CropRotations.FindAsync(id);

            if (cropRotation == null)
            {
                return(HttpNotFound());
            }
            if (ViewBag.Language == "ru")
            {
                ViewBag.CropRotationTypeId = new SelectList(db.CropRotationTypes, "Id", "NameRU", cropRotation.CropRotationTypeId);
            }
            if (ViewBag.Language == "en")
            {
                ViewBag.CropRotationTypeId = new SelectList(db.CropRotationTypes, "Id", "NameEN", cropRotation.CropRotationTypeId);
            }
            if (ViewBag.Language == "kk")
            {
                ViewBag.CropRotationTypeId = new SelectList(db.CropRotationTypes, "Id", "NameKK", cropRotation.CropRotationTypeId);
            }
            return(View(cropRotation));
        }
Esempio n. 3
0
        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 });
        }
Esempio n. 4
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            CropRotation cropRotation = await db.CropRotations.FindAsync(id);

            db.CropRotations.Remove(cropRotation);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Esempio n. 5
0
        public async Task <ActionResult> Delete(int?id)
        {
            ViewBag.Language = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CropRotation cropRotation = db.CropRotations
                                        .Where(c => c.Id == id)
                                        .Include(c => c.CropRotationType)
                                        .FirstOrDefault();

            if (cropRotation == null)
            {
                return(HttpNotFound());
            }
            return(View(cropRotation));
        }
Esempio n. 6
0
        public ActionResult Create()
        {
            ViewBag.Language = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
            if (ViewBag.Language == "ru")
            {
                ViewBag.CropRotationTypeId = new SelectList(db.CropRotationTypes, "Id", "NameRU");
            }
            if (ViewBag.Language == "en")
            {
                ViewBag.CropRotationTypeId = new SelectList(db.CropRotationTypes, "Id", "NameEN");
            }
            if (ViewBag.Language == "kk")
            {
                ViewBag.CropRotationTypeId = new SelectList(db.CropRotationTypes, "Id", "NameKK");
            }
            CropRotation cropRotation = new CropRotation()
            {
                Year = DateTime.Today.Year
            };

            return(View(cropRotation));
        }