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; }
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(); }
public void Delete(TcNotice model) { var target = Find(model.ID); db.Remove<TcNotice>(target); db.Commit(); }
public void Create(TcNotice model) { db.Add<TcNotice>(model); db.Commit(); }