Ejemplo n.º 1
0
 public virtual void Delete(SysEventViewModel sys, ModelStateDictionary modelState)
 {
     var entity = sys.ToEntity();
     db.SysEvents.Attach(entity);
     db.SysEvents.Remove(entity);
     db.SaveChanges();
 }
Ejemplo n.º 2
0
        public SysEventViewModel Init(string level, string message, string createBy)
        {
            var model = new SysEventViewModel
            {
                ID = ID,
                Level = level,
                Message = message,
                UpdateAt = DateTime.Now,
                CreateBy = createBy
            };

            return model;
        }
Ejemplo n.º 3
0
        public virtual void Insert(SysEventViewModel sys, ModelStateDictionary modelState)
        {
            if (ValidateModel(sys, modelState))
            {
                if (string.IsNullOrEmpty(sys.Message))
                {
                    sys.Message = "";
                }

                var entity = sys.ToEntity();

                db.SysEvents.Add(entity);
                db.SaveChanges();

                sys.ID = entity.ID;
            }
        }
Ejemplo n.º 4
0
 private bool ValidateModel(SysEventViewModel sys, ModelStateDictionary modelState)
 {
     return true;
 }
Ejemplo n.º 5
0
        public virtual void Update(SysEventViewModel sys, ModelStateDictionary modelState)
        {
            if (ValidateModel(sys, modelState))
            {
                if (string.IsNullOrEmpty(sys.Message))
                {
                    sys.Message = "";
                }
                var entity = sys.ToEntity();
                db.SysEvents.Attach(entity);

                db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }
        }
Ejemplo n.º 6
0
 private void NewSysEvent(string level, string message)
 {
     SysEventViewModel newEvent = new SysEventViewModel().Init(level, message, "System");
     eventService.Insert(newEvent, ModelState);
 }
Ejemplo n.º 7
0
 private SysEventViewModel ConvertToViewModel(FormCollection collection)
 {
     SysEventViewModel model = new SysEventViewModel();
     model.Level = Convert.ToString(collection.GetValues("Level")[0]);
     model.Message = Convert.ToString(collection.GetValues("Message")[0]);
     model.UpdateAt = DateTime.Now;
     model.CreateBy = "System";
     return model;
 }
Ejemplo n.º 8
0
        public JsonResult EditingPopup_Update([DataSourceRequest] DataSourceRequest request, SysEventViewModel rvm)
        {
            if (rvm != null && ModelState.IsValid)
            {
                eventService.Update(rvm, ModelState);
            }

            return Json(new[] { rvm }.ToDataSourceResult(request, ModelState));
        }
Ejemplo n.º 9
0
        public virtual JsonResult EditingPopup_Destroy([DataSourceRequest] DataSourceRequest request, SysEventViewModel evm)
        {
            if (ModelState.IsValid)
            {
                eventService.Delete(evm, ModelState);
            }

            return Json(new[] { evm }.ToDataSourceResult(request, ModelState));
        }