Exemplo n.º 1
0
        public object SaveTask(Task entity)
        {
            using (var db = new WeeklyEntities())
            {
                var loginner = FormsAuth.GetUserData<LoginerBase>();
                int execCount = 0;
                if (entity.Id == 0)
                {
                    entity.State = 1;
                    entity.CreateBy = loginner.Name;
                    entity.CreateById = loginner.UserID;
                    entity.CreateByDate = DateTime.Now;
                    db.Tasks.Add(entity);
                }
                else
                {
                    var oldEntity = db.Tasks.First(p => p.Id == entity.Id);
                    oldEntity.WeeklyYear = entity.WeeklyYear;
                    oldEntity.WeeklyWeeks = entity.WeeklyWeeks;
                    oldEntity.WeeklyBegin = entity.WeeklyBegin;
                    oldEntity.WeeklyEnd = entity.WeeklyEnd;
                    oldEntity.PlanBegin = entity.PlanBegin;
                    oldEntity.PlanEnd = entity.PlanEnd;
                }
                execCount = db.SaveChanges();

                if (execCount > 0)
                    return new { status = "success", message = "操作成功!" };
                else
                    return new { status = "error", message = "操作失败,请检查!" };
            }
        }
Exemplo n.º 2
0
 public ActionResult SaveTask(Task entity)
 {
     var message = new TaskService().SaveTask(entity);
     return Json(message, JsonRequestBehavior.DenyGet);
 }