public IUnitOfWorkGeneric <TEntity> CreateUoW <TEntity>(IUnitOfWorkFactory unitOfWorkFactory) where TEntity : class, IDomainObject, new() { if (IsNewEntity) { if (RootUoW == null) { return(unitOfWorkFactory.CreateWithNewRoot <TEntity>()); } else { return(unitOfWorkFactory.CreateWithNewChildRoot <TEntity>(RootUoW)); } } else { if (RootUoW == null) { return(unitOfWorkFactory.CreateForRoot <TEntity>(EntityOpenId)); } else { return(unitOfWorkFactory.CreateForChildRoot <TEntity>(RootUoW.GetById <TEntity>(EntityOpenId), RootUoW)); } } }
public IUnitOfWorkGeneric <TEntity> CreateUoW <TEntity>(IUnitOfWorkFactory unitOfWorkFactory, string UoWTitle = null) where TEntity : class, IDomainObject, new() { if (IsNewEntity) { return(unitOfWorkFactory.CreateWithNewRoot <TEntity>(UoWTitle)); } else { return(unitOfWorkFactory.CreateForRoot <TEntity>(EntityOpenId, UoWTitle)); } }
public void SaveSentMesage(string text, string messageId, string status) { using (var uow = unitOfWorkFactory.CreateWithNewRoot <SentMessage>()) { var entity = uow.Root; entity.WorkOrder = workOrder; entity.Text = text; entity.MessageId = messageId; entity.Phone = CustomerPhone; entity.SentTime = DateTime.Now; entity.User = userService.GetCurrentUser(uow); entity.LastStatus = status; entity.LastStatusTime = DateTime.Now; uow.Save(entity); } }
/// <summary> /// Создаем Unit of Work с новым экземляром сущности /// </summary> /// <returns>UnitOfWork.</returns> /// <typeparam name="TEntity">Тип объекта доменной модели, должен реализовывать интерфейс IDomainObject.</typeparam> public static IUnitOfWorkGeneric <TEntity> CreateWithNewRoot <TEntity>(string userActionTitle = null, [CallerMemberName] string callerMemberName = null, [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int callerLineNumber = 0) where TEntity : class, IDomainObject, new() { return(unitOfWorkFactory.CreateWithNewRoot <TEntity>(userActionTitle, callerMemberName, callerFilePath, callerLineNumber)); }