Exemplo n.º 1
0
        public object SaveNotice(Notice entity)
        {
            using (var db = new WeeklyEntities())
            {
                var loginner = FormsAuth.GetUserData<LoginerBase>();
                int execCount = 0;
                if (entity.Id == 0)
                {
                    entity.CreateBy = loginner.Name;
                    entity.CreateById = loginner.UserID;
                    entity.CreateByDate = DateTime.Now;
                    if (entity.State == 1)
                        entity.ReleaseDate = DateTime.Now;
                    db.Notices.Add(entity);
                }
                else
                {
                    var oldEntity = db.Notices.First(p => p.Id == entity.Id);
                    oldEntity.Title = entity.Title;
                    oldEntity.Content = entity.Content;
                    oldEntity.State = entity.State;
                    if (entity.State == 1)
                        oldEntity.ReleaseDate = DateTime.Now;
                }
                execCount = db.SaveChanges();

                if (execCount > 0)
                    return new { status = "success", message = "操作成功!" };
                else
                    return new { status = "error", message = "操作失败,请检查!" };
            }
        }
Exemplo n.º 2
0
        public object SavePlanSet(PlanSet entity)
        {
            using (var db = new WeeklyEntities())
            {
                var loginner = FormsAuth.GetUserData<LoginerBase>();
                int execCount = 0;
                if (entity.Id == 0)
                {
                    entity.CreateBy = loginner.Name;
                    entity.CreateById = loginner.UserID;
                    entity.CreateByDate = DateTime.Now;
                    db.PlanSets.Add(entity);
                }
                else
                {
                    var oldEntity = db.PlanSets.First(p => p.Id == entity.Id);
                    oldEntity.PBegin = entity.PBegin;
                    oldEntity.BeginDay = entity.BeginDay;
                    oldEntity.PEnd = entity.PEnd;
                    oldEntity.EndDay = entity.EndDay;
                    oldEntity.Content = entity.Content;
                    oldEntity.Place = entity.Place;
                    oldEntity.Leads = entity.Leads;
                    oldEntity.UndertakeDept = entity.UndertakeDept;
                    oldEntity.ParticipationDept = entity.ParticipationDept;
                    oldEntity.PState = entity.PState;
                }
                execCount = db.SaveChanges();

                if (execCount > 0)
                    return new { status = "success", message = "操作成功!" };
                else
                    return new { status = "error", message = "操作失败,请检查!" };
            }
        }
Exemplo n.º 3
0
        public object saveRole(Role entity)
        {
            using (var db = new WeeklyEntities())
            {
                var loginner = FormsAuth.GetUserData<LoginerBase>();
                int execCount = 0;
                if (entity.Id == 0)
                {
                    entity.CreateBy = loginner.Name;
                    entity.CreateById = loginner.UserID;
                    entity.CreateByDate = DateTime.Now;
                    db.Roles.Add(entity);
                }
                else
                {
                    var oldEntity = db.Roles.First(p => p.Id == entity.Id);
                    oldEntity.Name = entity.Name;
                    oldEntity.OrgTypeId = entity.OrgTypeId;
                }
                execCount = db.SaveChanges();

                if (execCount > 0)
                    return new { status = "success", message = "操作成功!" };
                else
                    return new { status = "error", message = "操作失败,请检查!" };
            }
        }
Exemplo n.º 4
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.º 5
0
 public object saveRoleMenu(List<RoleMenu> entitys)
 {
     delRoleMenu(entitys[0].RoleId);
     using (var db = new WeeklyEntities())
     {
         db.RoleMenus.AddRange(entitys);
         db.SaveChanges();
         return new { status = "success", message = "操作成功!" };
     }
 }
Exemplo n.º 6
0
 public object delRoleMenu(int? RoleID)
 {
     using (var db = new WeeklyEntities())
     {
         var roleMenus = db.RoleMenus.Where(m => m.RoleId == RoleID).ToList();
         if (roleMenus.Count > 0)
         {
             db.RoleMenus.RemoveRange(roleMenus);
             db.SaveChanges();
         }
         return new { status = "success", message = "操作成功!" };
     }
 }