Пример #1
0
        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));
            }
        }
Пример #2
0
 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));
     }
 }
Пример #3
0
 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;
     }
 }
Пример #4
0
        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;
            }
        }