public ActionResult Create2(int[] fieldid, Models.GapJournal collection) { try { if (fieldid.Count() == 0) { throw new Exception("Phải chọn thửa đất"); } var _dataobject2 = new DAL.GapField(Request); foreach (var item in fieldid) { //_dataobject.MapView2Table(); var gapfield = _dataobject2.GetEdit(item); if (gapfield.RefJournalId > 0) { continue; } collection.FieldId = item; int outputId = _dataobject.Insert(collection); gapfield.RefJournalId = outputId; _dataobject2.Update(gapfield); } return(RedirectToAction(this.ActionReturn())); } catch (Exception ex) { ViewBag.fieldid = fieldid; Services.GlobalErrors.Parse(ModelState, _dataobject.Errors, ex); return(PartialView(collection)); } }
public ActionResult Edit(int JournalId, Models.GapJournal 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.GapJournal data) { try { this.Validate(data); var _data = new Models.GapJournal(); this.MapView2Table(data, _data); this._db.GapJournals.Add(_data); this._db.SaveChanges(); return(_data.JournalId); } catch (Exception) { throw; } }
public int Update(Models.GapJournal data) { try { this.Validate(data); var _data = this.GetById2(data.JournalId); this.MapView2Table(data, _data); this._db.Entry(_data).State = System.Data.Entity.EntityState.Modified; this._db.SaveChanges(); return(data.JournalId); } catch (Exception) { throw; } }