public ActionResult FieldDetail(FieldDetailViewModel fvm)
        {
            decimal area = 0;
            string  url;

            // required to populate o/w validation messages are suppressed
            fvm.selPrevYrManureOptions = _sd.GetPrevManureApplicationInPrevYears();

            if (ModelState.IsValid)
            {
                if (!string.IsNullOrEmpty(fvm.fieldComment))
                {
                    if (fvm.fieldComment.Length > Convert.ToInt32(_appSettings.Value.CommentLength))
                    {
                        ModelState.AddModelError("fieldComment", "Comment length of " + fvm.fieldComment.Length.ToString() + " exceeds maximum of " + _appSettings.Value.CommentLength);
                        return(PartialView("FieldDetail", fvm));
                    }
                }
                try
                {
                    area = decimal.Parse(fvm.fieldArea);
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("fieldArea", "Invalid amount for area.");
                    _logger.LogError(ex, "FieldDetail Exception");
                    return(PartialView("FieldDetail", fvm));
                }
                if (fvm.selPrevYrManureOption == "select")
                {
                    ModelState.AddModelError("selPrevYrManureOption", "Manure application in previous years must be selected");
                    return(PartialView("FieldDetail", fvm));
                }

                Field fld = _ud.GetFieldDetails(fvm.fieldName);

                if (fld != null)
                {
                    if ((fvm.act == "Edit" & fvm.currFieldName != fvm.fieldName) |
                        fvm.act == "Add")
                    {
                        ModelState.AddModelError("fieldName", "A field already exists with this name.");
                        return(PartialView("FieldDetail", fvm));
                    }
                }

                if (fvm.act == "Add")
                {
                    fld = new Field();
                }
                else
                {
                    fld = _ud.GetFieldDetails(fvm.currFieldName);
                    if (fld == null)
                    {
                        fld = new Field();
                    }
                }

                fld.FieldName = fvm.fieldName;
                fld.Area      = Math.Round(area, 1);
                fld.Comment   = fvm.fieldComment;
                fld.PreviousYearManureApplicationFrequency = fvm.selPrevYrManureOption;

                if (fvm.act == "Add")
                {
                    _ud.AddField(fld);
                }
                else
                {
                    _ud.UpdateField(fld);
                }
                if (fvm.target == "#fields")
                {
                    url = Url.Action("RefreshFieldsList", "Fields");
                }
                else
                {
                    url = Url.Action(fvm.actn, fvm.cntl, new { nme = fld.FieldName });

                    //url = Url.Action("RefreshList", "Fields", new { cntl = fvm.cntl, actn = fvm.actn, currFld = fvm.currFld });
                }
                return(Json(new { success = true, url = url, target = fvm.target }));
            }
            return(PartialView("FieldDetail", fvm));
        }