Exemplo n.º 1
0
        public virtual JsonResult TaskEvents_Update([DataSourceRequest] DataSourceRequest request, TaskEventViewModel taskEvent)
        {
            if (ModelState.IsValid)
            {
                if (string.IsNullOrEmpty(taskEvent.Title))
                {
                    taskEvent.Title = "";
                }

                var entity = taskEvent.ToEntity();
                db.TaskEvents.Attach(entity);
                db.Entry(entity).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(Json(new[] { taskEvent }.ToDataSourceResult(request, ModelState)));
        }
Exemplo n.º 2
0
        public virtual JsonResult TaskEvents_Destroy([DataSourceRequest] DataSourceRequest request, TaskEventViewModel taskEvent)
        {
            if (ModelState.IsValid)
            {
                var entity = taskEvent.ToEntity();
                db.TaskEvents.Attach(entity);
                db.TaskEvents.Remove(entity);
                db.SaveChanges();
            }

            return(Json(new[] { taskEvent }.ToDataSourceResult(request, ModelState)));
        }
Exemplo n.º 3
0
        public virtual JsonResult TaskEvents_Create([DataSourceRequest] DataSourceRequest request, TaskEventViewModel taskEvent)
        {
            if (ModelState.IsValid)
            {
                if (string.IsNullOrEmpty(taskEvent.Title))
                {
                    taskEvent.Title = "";
                }

                var entity = taskEvent.ToEntity();
                db.TaskEvents.Add(entity);
                db.SaveChanges();
                taskEvent.Id = entity.Id;
            }

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