Esempio n. 1
0
        public TcNotice Create(ViewModels.TcNoticeViewModel model)
        {
            TcNotice entity = new TcNotice();
            entity.AddTime = DateTime.Now;
            entity.AddUser = CookieHelper.MemberID;
            entity.LastTime = DateTime.Now;
            entity.LastUser = CookieHelper.MemberID;
            entity.AttachmentPath = model.AttachmentPath;
            entity.Content = model.Content;
            entity.Name = model.Name;

            if (!string.IsNullOrEmpty(model.DepartmentID))
            {
                var DepartmentArray = model.DepartmentID.Split(',').Select(x => Convert.ToInt32(x)).ToList();
                var DepartmentList = DepartmentService.GetALL().Where(x => DepartmentArray.Contains(x.ID));
                entity.Department.AddRange(DepartmentList);
            }
            db.Add<TcNotice>(entity);
            db.Commit();
            return entity;
        }
Esempio n. 2
0
 public void Update(TcNotice model)
 {
     var target = Find(model.ID);
     db.Attach<TcNotice>(target);
     target.Name = model.Name;
     target.Content = model.Content;
     target.AttachmentPath = model.AttachmentPath;
     db.Commit();
 }
Esempio n. 3
0
 public void Delete(TcNotice model)
 {
     var target = Find(model.ID);
     db.Remove<TcNotice>(target);
     db.Commit();
 }
Esempio n. 4
0
 public void Create(TcNotice model)
 {
     db.Add<TcNotice>(model);
     db.Commit();
 }