public ActionResult Edit(int JournalHarvestId, Models.GapJournalHarvest collection) { try { int outputId = _dataobject.Update(collection); return(RedirectToAction(this.ActionReturn())); } catch (Exception ex) { Services.GlobalErrors.Parse(ModelState, _dataobject.Errors, ex); return(PartialView(this._updateview, collection)); } }
public int Insert(Models.GapJournalHarvest data) { try { this.Validate(data); var _data = new Models.GapJournalHarvest(); this.MapView2Table(data, _data); this._db.GapJournalHarvests.Add(_data); this._db.SaveChanges(); return(data.JournalHarvestId); } catch (Exception) { throw; } }
public int Update(Models.GapJournalHarvest data) { try { this.Validate(data); var _data = this.GetById2(data.JournalHarvestId); this.MapView2Table(data, _data); this._db.Entry(_data).State = System.Data.Entity.EntityState.Modified; this._db.SaveChanges(); return(data.JournalHarvestId); } catch (Exception) { throw; } }
public ActionResult Create2(int[] fieldid, Models.GapJournalHarvest collection) { try { if (fieldid.Count() == 0) { throw new Exception("Phải chọn thửa đất"); } var _dataobject2 = new DAL.GapField(Request); var _dataobject3 = new DAL.GapJournal(Request); foreach (var item in fieldid) { //_dataobject.MapView2Table(); var gapfield = _dataobject2.GetEdit(item); if (gapfield.RefJournalId != null) { var gapjournal = _dataobject3.GetById2(gapfield.RefJournalId.Value); if (gapjournal.IsolationDateEnd() > DateTime.Today) { continue; } collection.JournalId = gapjournal.JournalId; collection.RefIsolationDate = gapjournal.IsolationDate; collection.RefIsolationDay = gapjournal.IsolationDay; int outputId = _dataobject.Insert(collection); } } return(RedirectToAction(this.ActionReturn())); } catch (Exception ex) { ViewBag.fieldid = fieldid; Services.GlobalErrors.Parse(ModelState, _dataobject.Errors, ex); return(PartialView(collection)); } }