public void Remove(MsgEmployee msEmp) { if (Context.Entry(msEmp).State == EntityState.Detached) { context.MsgEmployees.Attach(msEmp); } context.MsgEmployees.Remove(msEmp); }
public void Send(int Id, int CompanyId) { var Massges = context.Messages.Where(m => m.Id == Id).FirstOrDefault(); IQueryable <Assignment> ActiveAssignments; if (Massges.All) { ActiveAssignments = context.Assignments.Where(a => ((a.AssignDate <= DateTime.Today && a.EndDate >= DateTime.Today) && a.CompanyId == CompanyId)); } else { List <int> Depts = Massges.Depts != null?Massges.Depts.Split(',').Select(int.Parse).ToList() : new List <int>(); List <int> Jobs = Massges.Jobs != null?Massges.Jobs.Split(',').Select(int.Parse).ToList() : new List <int>(); List <int> PeopleGroups = Massges.PeopleGroups != null?Massges.PeopleGroups.Split(',').Select(int.Parse).ToList() : new List <int>(); List <int> Employees = Massges.Employees != null?Massges.Employees.Split(',').Select(int.Parse).ToList() : new List <int>(); ActiveAssignments = context.Assignments.Where(a => ((a.AssignDate <= DateTime.Today && a.EndDate >= DateTime.Today) && a.CompanyId == CompanyId) && (Depts.Contains(a.DepartmentId) || Jobs.Contains(a.JobId) || PeopleGroups.Contains(a.GroupId.Value) || Employees.Contains(a.EmpId))); } foreach (var AllAssign in ActiveAssignments.ToList()) { MsgEmployee newMessage = new MsgEmployee() { Message = Massges, MessageId = Massges.Id, FromEmpId = Massges.FromEmpId, ToEmp = AllAssign.Employee, ToEmpId = AllAssign.EmpId }; context.MsgEmployees.Add(newMessage); } if (ActiveAssignments.Count() > 0) { context.SaveChanges(); } }
public void Attach(MsgEmployee msEmp) { context.MsgEmployees.Attach(msEmp); }
public DbEntityEntry <MsgEmployee> Entry(MsgEmployee msEmp) { return(Context.Entry(msEmp)); }
public void Add(MsgEmployee msEmp) { context.MsgEmployees.Add(msEmp); }