/// <summary> /// Изменить объект. /// </summary> /// <param name="entity">Объект.</param> public void Update(Party entity) { BusinessTripContext businessTripContext = new BusinessTripContext(); businessTripContext.Entry(entity).State = EntityState.Modified; businessTripContext.SaveChanges(); }
/// <summary> /// Редактирование командировки. /// </summary> /// <param name="businessTrip">Командировка.</param> /// <param name="AddDirectionIds">Ид новых направлений у командировки.</param> /// <param name="DeleteDirectionIds">Ид направлений, которые необходимо удалить.</param> public void UpdateParty(Party party, List <int> addPersonIds, List <int> deletePersonIds) { using (var businessTripContex = new BusinessTripContext()) { businessTripContex.Entry(party).State = EntityState.Modified; foreach (var personId in deletePersonIds) { var partyPerson = new PartyPerson { Party_PartyId = party.PartyId, Person_PersonId = personId }; businessTripContex.Entry(partyPerson).State = EntityState.Deleted; } foreach (var personId in addPersonIds) { var partyPerson = new PartyPerson { Party_PartyId = party.PartyId, Person_PersonId = personId }; businessTripContex.Entry(partyPerson).State = EntityState.Added; } businessTripContex.SaveChanges(); } }
/// <summary> /// Сохранить объект. /// </summary> /// <param name="entity">Объект.</param> public void Save(Core.BusinessTrip.Domain.BusinessTrip entity) { BusinessTripContext businessTripContext = new BusinessTripContext(); businessTripContext.Entry(entity).State = EntityState.Added; businessTripContext.SaveChanges(); }
/// <summary> /// Изменить объект. /// </summary> /// <param name="entity">Объект.</param> public void Update(Core.BusinessTrip.Domain.BusinessTrip entity) { BusinessTripContext businessTripContext = new BusinessTripContext(); businessTripContext.Entry <Core.BusinessTrip.Domain.BusinessTrip>(entity).State = EntityState.Modified; businessTripContext.SaveChanges(); }
/// <summary> /// Изменить объект. /// </summary> /// <param name="entity">Объект.</param> public void Update(Core.BusinessTrip.Domain.BusinessTrip entity) { using (BusinessTripContext businessTripContext = new BusinessTripContext(ConnectionString)) { businessTripContext.Configuration.AutoDetectChangesEnabled = false; businessTripContext.Configuration.ValidateOnSaveEnabled = false; var com = entity.Command; com.BusinessTripId = entity.BusinessTripId; businessTripContext.Entry <Command>(com).State = EntityState.Modified; entity.Command = null; var requestTransport = entity.RequestTransport; requestTransport.BusinessTripId = entity.BusinessTripId; businessTripContext.Entry <RequestTransport>(requestTransport).State = EntityState.Modified; entity.RequestTransport = null; businessTripContext.Entry <Core.BusinessTrip.Domain.BusinessTrip>(entity).State = EntityState.Modified; businessTripContext.Database.Log = (s => System.Diagnostics.Debug.WriteLine(s)); businessTripContext.SaveChanges(); businessTripContext.Configuration.AutoDetectChangesEnabled = true; businessTripContext.Configuration.ValidateOnSaveEnabled = true; } }
/// <summary> /// Изменить объект. /// </summary> /// <param name="entity">Объект.</param> public void Update(TEntity entity) { BusinessTripContext businessTripContext = new BusinessTripContext(ConnectionString); businessTripContext.Entry <TEntity>(entity).State = EntityState.Modified; businessTripContext.SaveChanges(); }
/// <summary> /// Получение направлений по Ид командировки. /// </summary> /// <param name="businessTripId">Ид командировки.</param> /// <returns>Список направлений.</returns> public List <Direction> GetDirectionsByBusinessTripId(int businessTripId) { using (var businessTripContext = new BusinessTripContext()) { return(businessTripContext.Directions.Include(l => l.Location) .Include(o => o.Organization).Where(d => d.BusinessTripId == businessTripId).ToList()); } }
/// <summary> /// Получить все объекты. /// </summary> /// <returns>Объекты.</returns> public List <Core.BusinessTrip.Domain.BusinessTrip> GetAll() { BusinessTripContext businessTripContext = new BusinessTripContext(ConnectionString); //var ff = businessTripContext.Set<Core.BusinessTrip.Domain.BusinessTrip>().ToList(); //businessTripContext.Database.Log = (s => System.Diagnostics.Debug.WriteLine(s)); businessTripContext.Database.Log = (s => System.Diagnostics.Debug.WriteLine(s)); return(businessTripContext.Set <Core.BusinessTrip.Domain.BusinessTrip>().ToList()); }
/// <summary> /// Сохранить объект. /// </summary> /// <param name="entity">Объект.</param> public Party Save(Party entity) { BusinessTripContext businessTripContext = new BusinessTripContext(ConnectionString); businessTripContext.Entry(entity).State = EntityState.Added; businessTripContext.SaveChanges(); return(entity); }
public List <Core.BusinessTrip.Domain.BusinessTrip> GetBusinessTripFullByIds(List <int> businessTripIds) { using (var businessTripContext = new BusinessTripContext(ConnectionString)) { businessTripContext.Database.Log = (s => System.Diagnostics.Debug.WriteLine(s)); return(businessTripContext.BusinessTrips .Include(c => c.Command).ToList()); } }
/// <summary> /// Удалить объекты. /// </summary> /// <param name="entities">Объекты.</param> public void Delete(List <Core.BusinessTrip.Domain.BusinessTrip> entities) { BusinessTripContext businessTripContext = new BusinessTripContext(); foreach (Core.BusinessTrip.Domain.BusinessTrip entity in entities) { businessTripContext.Entry <Core.BusinessTrip.Domain.BusinessTrip>(entity).State = EntityState.Deleted; } businessTripContext.SaveChanges(); }
/// <summary> /// Удалить объекты. /// </summary> /// <param name="entities">Объекты.</param> public void Delete(List <Party> entities) { BusinessTripContext businessTripContext = new BusinessTripContext(); foreach (Party entity in entities) { businessTripContext.Entry(entity).State = EntityState.Deleted; } businessTripContext.SaveChanges(); }
/// <summary> /// Сохранение командировки. /// </summary> /// <param name="businessTrip">Командировка.</param> /// <returns>Ид новой командировки.</returns> public int SaveBusinessTrip(Core.BusinessTrip.Domain.BusinessTrip businessTrip) { using (var businessTripContex = new BusinessTripContext()) { businessTripContex.BusinessTrips.Add(businessTrip); businessTripContex.SaveChanges(); return(businessTrip.BusinessTripId); } }
/// <summary> /// Получение направлений по Ид командировки. /// </summary> /// <param name="businessTripId">Ид командировки.</param> /// <returns>Список направлений.</returns> public List <Direction> GetDirectionsByBusinessTripId(int businessTripId) { using (var businessTripContext = new BusinessTripContext(ConnectionString)) { businessTripContext.Database.Log = (s => System.Diagnostics.Debug.WriteLine(s)); return(businessTripContext.Directions.Include(l => l.Location) .Include(o => o.Organization).Where(d => d.BusinessTripId == businessTripId).ToList()); } }
/// <summary> /// Сохранение командировки. /// </summary> /// <param name="businessTrip">Командировка.</param> public Core.BusinessTrip.Domain.BusinessTrip SaveBusinessTrip(Core.BusinessTrip.Domain.BusinessTrip businessTrip) { using (var businessTripContext = new BusinessTripContext(ConnectionString)) { businessTripContext.BusinessTrips.Add(businessTrip); businessTripContext.Database.Log = (s => System.Diagnostics.Debug.WriteLine(s)); businessTripContext.SaveChanges(); return(businessTrip); } }
public List <PartyPerson> GetPartyPersonsByPartyId(int partyId) { using (var businessTripContext = new BusinessTripContext(ConnectionString)) { businessTripContext.Database.Log = (s => System.Diagnostics.Debug.WriteLine(s)); return(businessTripContext.PartysPersons .Include(p => p.Party) .Include(p => p.Person) .Include(p => p.Person.Position) .Include(p => p.Person.Department).Where(p => p.Party_PartyId == partyId).ToList()); } }
/// <summary> /// Сохранить объект. /// </summary> /// <param name="entity">Объект.</param> public Core.BusinessTrip.Domain.BusinessTrip Save(Core.BusinessTrip.Domain.BusinessTrip entity) { BusinessTripContext businessTripContext = new BusinessTripContext(ConnectionString); businessTripContext.Configuration.AutoDetectChangesEnabled = false; businessTripContext.Configuration.ValidateOnSaveEnabled = false; businessTripContext.Entry(entity).State = EntityState.Added; businessTripContext.Database.Log = (s => System.Diagnostics.Debug.WriteLine(s)); businessTripContext.SaveChanges(); businessTripContext.Configuration.AutoDetectChangesEnabled = true; businessTripContext.Configuration.ValidateOnSaveEnabled = true; return(entity); }
/// <summary> /// Удаление направлений по Ид. /// </summary> /// <param name="directionIds">Ид направлений.</param> public void DeleteDirectionByIds(List <int> directionIds) { using (var businessTripContex = new BusinessTripContext()) { foreach (var directionId in directionIds) { var direction = new Direction { DirectionId = directionId }; businessTripContex.Directions.Attach(direction); businessTripContex.Directions.Remove(direction); } businessTripContex.SaveChanges(); } }
/// <summary> /// Удалить объекты. /// </summary> /// <param name="entities">Объекты.</param> public void Delete(List <TEntity> entities) { BusinessTripContext businessTripContext = new BusinessTripContext(); businessTripContext.Configuration.AutoDetectChangesEnabled = false; businessTripContext.Configuration.ValidateOnSaveEnabled = false; foreach (TEntity entity in entities) { businessTripContext.Entry <TEntity>(entity).State = EntityState.Deleted; } businessTripContext.SaveChanges(); businessTripContext.Configuration.AutoDetectChangesEnabled = true; businessTripContext.Configuration.ValidateOnSaveEnabled = true; }
/// <summary> /// Удаление направлений по Ид. /// </summary> /// <param name="directionIds">Ид направлений.</param> public void DeleteDirectionByIds(List <int> directionIds) { using (var businessTripContext = new BusinessTripContext(ConnectionString)) { foreach (var directionId in directionIds) { var direction = new Direction { DirectionId = directionId }; businessTripContext.Directions.Attach(direction); businessTripContext.Directions.Remove(direction); } businessTripContext.Database.Log = (s => System.Diagnostics.Debug.WriteLine(s)); businessTripContext.SaveChanges(); } }
public Dictionary <string, string> GetTargetsByReasons(List <string> reasons) { using (var businessTripContext = new BusinessTripContext("Server=as21430; Initial Catalog=ContractsPIR; Integrated Security = True;", true)) { if (reasons.Count == 0) { return(null); } var sqlString = string.Format("Select [CodeProjectP] AS [Code],[NameProject] AS [Target] From [Table_ContractsPIR] Where [CodeProjectP] in ({0})", string.Join(", ", reasons.Distinct().Select(a => string.Format("'{0}'", a)))); businessTripContext.Database.Log = (s => System.Diagnostics.Debug.WriteLine(s)); return(businessTripContext.Database.SqlQuery <ContractPIR>(sqlString).ToDictionary(c => c.Code, c => c.Target.TrimStart(' ').TrimEnd(' '))); } }
/// <summary> /// Удалить объекты. /// </summary> /// <param name="entities">Объекты.</param> public void Delete(List <Core.BusinessTrip.Domain.BusinessTrip> entities) { BusinessTripContext businessTripContext = new BusinessTripContext(ConnectionString); foreach (Core.BusinessTrip.Domain.BusinessTrip entity in entities) { businessTripContext.Entry <Command>(new Command { BusinessTripId = entity.BusinessTripId }).State = EntityState.Deleted; businessTripContext.Entry <RequestTransport>(new RequestTransport { BusinessTripId = entity.BusinessTripId }).State = EntityState.Deleted; businessTripContext.Entry <Core.BusinessTrip.Domain.BusinessTrip>(entity).State = EntityState.Deleted; } businessTripContext.Database.Log = (s => System.Diagnostics.Debug.WriteLine(s)); businessTripContext.SaveChanges(); }
/// <summary> /// Сохранение командировки. /// </summary> /// <param name="businessTrip">Командировка.</param> /// <param name="DirectionIds">Ид направлений.</param> public void SaveParty(Party party, List <int> personIds) { using (var businessTripContex = new BusinessTripContext()) { businessTripContex.Partys.Add(party); businessTripContex.SaveChanges(); foreach (var personId in personIds) { businessTripContex.PartysPersons.Add(new PartyPerson { Party_PartyId = party.PartyId, Person_PersonId = personId }); } businessTripContex.SaveChanges(); } }
/// <summary> /// Сохранение партии. /// </summary> /// <param name="party">Партия.</param> /// <param name="persons">Список сотрудников.</param> public Party SaveParty(Party party, List <PartyPerson> persons) { using (var businessTripContex = new BusinessTripContext(ConnectionString)) { businessTripContex.Partys.Add(party); businessTripContex.SaveChanges(); foreach (var person in persons) { businessTripContex.PartysPersons.Add(new PartyPerson { Party_PartyId = party.PartyId, Person_PersonId = person.Person_PersonId, IsResponsible = person.IsResponsible }); } businessTripContex.SaveChanges(); return(party); } }
/// <summary> /// Обновление партии. /// </summary> /// <param name="party">Партия.</param> /// <param name="addPersons">Новые сотрудники в партии.</param> /// <param name="deletePersons">Сотрудники в партии к удалению.</param> /// <param name="editPersons">Сотрудники в партии для редактирования.</param> public void UpdateParty(Party party, List <PartyPerson> addPersons, List <PartyPerson> deletePersons, List <PartyPerson> editPersons) { using (var businessTripContex = new BusinessTripContext(ConnectionString)) { businessTripContex.Entry(party).State = EntityState.Modified; foreach (var person in deletePersons) { businessTripContex.Entry(person).State = EntityState.Deleted; //var partyPerson = new PartyPerson //{ // Party_PartyId = party.PartyId, // Person_PersonId = personId //}; //businessTripContex.Entry(partyPerson).State = EntityState.Deleted; } foreach (var person in addPersons) { businessTripContex.Entry(person).State = EntityState.Added; //var partyPerson = new PartyPerson //{ // Party_PartyId = party.PartyId, // Person_PersonId = person.Key, // IsResponsible = person.Value //}; //businessTripContex.Entry(partyPerson).State = EntityState.Added; } foreach (var person in editPersons) { businessTripContex.Entry(person).State = EntityState.Modified; } businessTripContex.SaveChanges(); } }
public ApplicationsController(BusinessTripContext context) { _context = context; }
/// <summary> /// Получить все объекты. /// </summary> /// <returns>Объекты.</returns> public List <Party> GetAll() { BusinessTripContext businessTripContext = new BusinessTripContext(); return(businessTripContext.Set <Party>().ToList()); }
public ProjectsController(BusinessTripContext context) { _context = context; }
/// <summary> /// Получить все объекты. /// </summary> /// <returns>Объекты.</returns> public List <Core.BusinessTrip.Domain.BusinessTrip> GetAll() { BusinessTripContext businessTripContext = new BusinessTripContext(); return(businessTripContext.Set <Core.BusinessTrip.Domain.BusinessTrip>().ToList()); }
public AccountController(BusinessTripContext _db) { db = _db; }