internal IFacadeUpdateResult <CollectionData> SaveCollectionItem(object parentId, CollectionItemData childDto) { ArgumentValidator.IsNotNull("parentId", parentId); ArgumentValidator.IsNotNull("childDto", childDto); FacadeUpdateResult <CollectionData> result = new FacadeUpdateResult <CollectionData>(); ICollectionService service = UnitOfWork.GetService <ICollectionService>(); Collection instance = RetrieveOrNew <CollectionData, Collection, ICollectionService>(result.ValidationResult, childDto.Id); if (result.IsSuccessful) { CollectionItem collectionItem = RetrieveOrNewCollectionItem(instance, childDto.Id); if (collectionItem != null) { collectionItem.ReferenceId = childDto.ReferenceId; collectionItem.Sort = childDto.Sort; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <CollectionData>()); result.Merge(saveQuery); } else { AddError(result.ValidationResult, "CollectionItemCannotBeFound"); } } return(result); }
internal IFacadeUpdateResult <ReviewData> SaveReview(ReviewInfoDto dto, ReviewObjectTypes type) { ArgumentValidator.IsNotNull("dto", dto); FacadeUpdateResult <ReviewData> result = new FacadeUpdateResult <ReviewData>(); IReviewService service = UnitOfWork.GetService <IReviewService>(); Review instance = RetrieveOrNew <ReviewData, Review, IReviewService>(result.ValidationResult, dto.ReviewId); if (result.IsSuccessful) { instance.ObjectTypeId = (int)type; instance.ObjectId = dto.ObjectId; instance.Rating = dto.Rating; instance.Title = dto.Title; instance.Content = dto.Content; instance.IssuedById = dto.IssuedById; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <ReviewData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <SetupMenuData> SaveSetupMenu(SetupMenuDto dto) { ArgumentValidator.IsNotNull("dto", dto); FacadeUpdateResult <SetupMenuData> result = new FacadeUpdateResult <SetupMenuData>(); ISetupMenuService service = UnitOfWork.GetService <ISetupMenuService>(); SetupMenu instance = RetrieveOrNew <SetupMenuData, SetupMenu, ISetupMenuService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { instance.Name = dto.Name; instance.ParentMenuId = dto.ParentMenuId; instance.MenuText = dto.MenuText; instance.Tooltip = dto.Tooltip; instance.NavigateUrl = dto.NavigateUrl; instance.Sort = dto.Sort; instance.MenuTypeId = dto.MenuTypeId; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <SetupMenuData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <SubsiteData> SaveSubsite(SubsiteData dto) { ArgumentValidator.IsNotNull("dto", dto); FacadeUpdateResult <SubsiteData> result = new FacadeUpdateResult <SubsiteData>(); ISubsiteService service = UnitOfWork.GetService <ISubsiteService>(); Subsite instance = RetrieveOrNew <SubsiteData, Subsite, ISubsiteService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { instance.Address = dto.Address; instance.Phone = dto.Phone; instance.Fax = dto.Fax; instance.Email = dto.Email; instance.Website = dto.Website; instance.BackColor = dto.BackColor; instance.TitleColor = dto.TitleColor; instance.BannerUrl = dto.BannerUrl; if (dto.SubsiteFolderId != null) { instance.SubsiteFolderId = dto.SubsiteFolderId; } instance.DefaultLanguageId = dto.DefaultLanguageId; instance.DefaultLocationId = dto.DefaultLocationId; instance.BannerHeight = dto.BannerHeight; instance.IsPublished = dto.IsPublished; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <SubsiteData>()); result.Merge(saveQuery); } return(result); }
internal FacadeUpdateResult <FolderData> SaveFolder(FolderData dto) { ArgumentValidator.IsNotNull("dto", dto); FacadeUpdateResult <FolderData> result = new FacadeUpdateResult <FolderData>(); IFolderService service = UnitOfWork.GetService <IFolderService>(); Folder instance = RetrieveOrNew <FolderData, Folder, IFolderService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { instance.Name = dto.Name; instance.Slug = dto.Slug; instance.ParentId = dto.ParentId; instance.FolderType = dto.FolderType; instance.Sort = dto.Sort; instance.IsPublished = dto.IsPublished; instance.IsSubsiteRoot = dto.IsSubsiteRoot; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <FolderData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <ProjectData> DeleteTask(object childId, object parentId) { ArgumentValidator.IsNotNull("parentId", parentId); ArgumentValidator.IsNotNull("childId", childId); FacadeUpdateResult <ProjectData> result = new FacadeUpdateResult <ProjectData>(); IProjectService service = UnitOfWork.GetService <IProjectService>(); var query = service.Retrieve(parentId); if (query.HasResult) { Project project = query.ToBo <Project>(); Task task = project.ProjectTasks.SingleOrDefault(o => o.Id.Equals(childId)); if (task != null) { project.ProjectTasks.Remove(task); var saveQuery = project.Save(); result.Merge(saveQuery); result.AttachResult(project.RetrieveData <ProjectData>()); } else { AddError(result.ValidationResult, "TaskCannotBeFound"); } } else { AddError(result.ValidationResult, "ProjectCannotBeFound"); } return(result); }
internal IFacadeUpdateResult <ScheduleEventData> SaveScheduleEvent(ScheduleEventDto dto) { ArgumentValidator.IsNotNull("dto", dto); FacadeUpdateResult <ScheduleEventData> result = new FacadeUpdateResult <ScheduleEventData>(); IScheduleEventService service = UnitOfWork.GetService <IScheduleEventService>(); ScheduleEvent instance = RetrieveOrNew <ScheduleEventData, ScheduleEvent, IScheduleEventService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { instance.Name = dto.Name; instance.ScheduledTime = dto.ScheduledTime; instance.ObjectId = dto.ObjectId; instance.ObjectTypeId = dto.ObjectTypeId; instance.ReccuringTypeId = dto.ReccuringTypeId; instance.StartDate = dto.StartDate; instance.EndDate = dto.EndDate; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <ScheduleEventData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <ReferenceData> SaveReferenceKeywords(object referenceId, IList <ReferenceKeywordData> referenceKeywords) { ArgumentValidator.IsNotNull("referenceId", referenceId); ArgumentValidator.IsNotNull("referenceKeywords", referenceKeywords); FacadeUpdateResult <ReferenceData> result = new FacadeUpdateResult <ReferenceData>(); IReferenceService service = UnitOfWork.GetService <IReferenceService>(); Reference instance = RetrieveOrNew <ReferenceData, Reference, IReferenceService>(result.ValidationResult, referenceId); if (result.IsSuccessful) { instance.ModifiedDate = DateTime.Now; // Remove all existing ReferenceKeywords instance.ReferenceKeywords.Clear(); // Keywords foreach (ReferenceKeywordData item in referenceKeywords) { ReferenceKeyword child = instance.ReferenceKeywords.AddNewBo(); child.KeywordId = item.KeywordId; child.Sort = item.Sort; } var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <ReferenceData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <GridRowData> SaveGridRow(GridRowData row) { ArgumentValidator.IsNotNull("row", row); FacadeUpdateResult <GridRowData> result = new FacadeUpdateResult <GridRowData>(); IGridRowService service = UnitOfWork.GetService <IGridRowService>(); GridRow instance = RetrieveOrNew <GridRowData, GridRow, IGridRowService>(result.ValidationResult, row.Id); if (result.IsSuccessful) { // Grid cells if (instance.IsNew) { instance.ReferenceId = row.ReferenceId; instance.GridId = row.GridId; instance.Sort = row.Sort; // Save row first var saveRowQuery = service.Save(instance); // Then save cells foreach (GridCellData newValue in row.Cells) { GridCell child = instance.Cells.AddNewBo(); child.GridColumnId = newValue.GridColumnId; child.ValueText = newValue.ValueText; child.ValueHtml = newValue.ValueHtml; child.ValueInt = newValue.ValueInt; child.ValueDate = newValue.ValueDate; child.ValueUrl = newValue.ValueUrl; } } else { foreach (GridCellData newValue in row.Cells) { GridCell child = instance.Cells.SingleOrDefault(o => object.Equals(o.GridColumnId, newValue.GridColumnId)); if (child != null) { child.GridColumnId = newValue.GridColumnId; child.ValueText = newValue.ValueText; child.ValueHtml = newValue.ValueHtml; child.ValueInt = newValue.ValueInt; child.ValueDate = newValue.ValueDate; child.ValueUrl = newValue.ValueUrl; } else { AddError(result.ValidationResult, "GridCellCannotBeFound"); } } } var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <GridRowData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <QuoteData> SaveQuoteLine(object parentId, QuoteLineDto childDto) { ArgumentValidator.IsNotNull("parentId", parentId); ArgumentValidator.IsNotNull("childDto", childDto); FacadeUpdateResult <QuoteData> result = new FacadeUpdateResult <QuoteData>(); IQuoteService service = UnitOfWork.GetService <IQuoteService>(); var parentQuery = service.Retrieve(parentId); if (parentQuery.HasResult) { Quote parent = parentQuery.ToBo <Quote>(); QuoteLine child = RetrieveOrNewQuoteLine(parent, childDto.Id); if (child != null) { child.ProductId = childDto.ProductId; child.Quantity = childDto.Quantity; child.TargetPrice = childDto.TargetPrice; var saveQuery = service.Save(parent); result.Merge(saveQuery); result.AttachResult(parent.RetrieveData <QuoteData>()); } else { AddError(result.ValidationResult, "QuoteLineCannotBeFound"); } } return(result); }
internal IFacadeUpdateResult <ReferenceData> SaveReferenceLanguageBasic(ReferenceData dto, object languageId) { ArgumentValidator.IsNotNull("dto", dto); ArgumentValidator.IsNotNull("languageId", languageId); FacadeUpdateResult <ReferenceData> result = new FacadeUpdateResult <ReferenceData>(); IReferenceService service = UnitOfWork.GetService <IReferenceService>(); Reference instance = RetrieveOrNew <ReferenceData, Reference, IReferenceService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { instance.ModifiedDate = DateTime.Now; // Check existence of current language ReferenceLanguage referenceLanguage = instance.ReferenceLanguages.FirstOrDefault(o => object.Equals(o.LanguageId, languageId)); if (referenceLanguage == null) { referenceLanguage = instance.ReferenceLanguages.AddNewBo(); referenceLanguage.LanguageId = languageId; } referenceLanguage.Title = dto.Title; referenceLanguage.Description = dto.Description; referenceLanguage.Keywords = dto.Keywords; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <ReferenceData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <ShipToData> SaveShipTo(ShipToDto dto) { ArgumentValidator.IsNotNull("dto", dto); FacadeUpdateResult <ShipToData> result = new FacadeUpdateResult <ShipToData>(); IShipToService service = UnitOfWork.GetService <IShipToService>(); ShipTo instance = RetrieveOrNew <ShipToData, ShipTo, IShipToService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { instance.Code = dto.Code; instance.CustomerId = dto.CustomerId; instance.ContactPerson = dto.ContactPerson; instance.ContactPhone = dto.ContactPhone; instance.AddressLine1 = dto.AddressLine1; instance.AddressLine2 = dto.AddressLine2; instance.Country = dto.Country; instance.CountryState = dto.CountryState; instance.City = dto.City; instance.ZipCode = dto.ZipCode; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <ShipToData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <ReviewData> SaveReview(ReviewData dto, object refId) { ArgumentValidator.IsNotNull("dto", dto); FacadeUpdateResult <ReviewData> result = new FacadeUpdateResult <ReviewData>(); IReviewService service = UnitOfWork.GetService <IReviewService>(); Review instance = RetrieveOrNew <ReviewData, Review, IReviewService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { instance.ReferenceId = refId; instance.Title = dto.Title; instance.Content = dto.Content; instance.IssuedBy = dto.IssuedBy; instance.IssuedByEmail = dto.IssuedByEmail; instance.IsPublished = dto.IsPublished; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <ReviewData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <DomainData> SaveDomainMainMenu(object parentId, DomainMainMenuDto childDto) { ArgumentValidator.IsNotNull("parentId", parentId); ArgumentValidator.IsNotNull("childDto", childDto); FacadeUpdateResult <DomainData> result = new FacadeUpdateResult <DomainData>(); IDomainService service = UnitOfWork.GetService <IDomainService>(); var parentQuery = service.Retrieve(parentId); if (parentQuery.HasResult) { Domain parent = parentQuery.ToBo <Domain>(); DomainMainMenu child = RetrieveOrNewDomainMainMenu(parent, childDto.Id); if (child != null) { child.MainMenuId = childDto.MainMenuId; child.Sort = childDto.Sort; var saveQuery = service.Save(parent); result.Merge(saveQuery); result.AttachResult(parent.RetrieveData <DomainData>()); } else { AddError(result.ValidationResult, "DomainMainMenuCannotBeFound"); } } return(result); }
internal IFacadeUpdateResult <ContactData> SaveContactContactMethod(object parentId, ContactContactMethodDto childDto) { ArgumentValidator.IsNotNull("parentId", parentId); ArgumentValidator.IsNotNull("childDto", childDto); FacadeUpdateResult <ContactData> result = new FacadeUpdateResult <ContactData>(); IContactService projectService = UnitOfWork.GetService <IContactService>(); var projectQuery = projectService.Retrieve(parentId); if (projectQuery.HasResult) { Contact parent = projectQuery.ToBo <Contact>(); ContactContactMethod child = RetrieveOrNewContactContactMethod(parent, childDto.Id); if (child != null) { child.ContactMethodTypeId = childDto.ContactMethodTypeId; child.ContactMethodValue = childDto.ContactMethodValue; var saveQuery = projectService.Save(parent); result.Merge(saveQuery); result.AttachResult(parent.RetrieveData <ContactData>()); } else { AddError(result.ValidationResult, "ContactContactMethodCannotBeFound"); } } return(result); }
internal IFacadeUpdateResult <ReferenceData> SetPublish(object instanceId, bool status) { ArgumentValidator.IsNotNull("instanceId", instanceId); FacadeUpdateResult <ReferenceData> result = new FacadeUpdateResult <ReferenceData>(); IReferenceService service = UnitOfWork.GetService <IReferenceService>(); var query = service.Retrieve(instanceId); if (query.HasResult) { Reference instance = query.ToBo <Reference>(); if (instance.IsPublished != status) { instance.IsPublished = status; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <ReferenceData>()); result.Merge(saveQuery); } } else { AddError(result.ValidationResult, "ReferenceCannotBeFound"); } return(result); }
internal IFacadeUpdateResult <UserData> SaveUser(UserDto dto) { ArgumentValidator.IsNotNull("dto", dto); FacadeUpdateResult <UserData> result = new FacadeUpdateResult <UserData>(); IUserService service = UnitOfWork.GetService <IUserService>(); User instance = RetrieveOrNew <UserData, User, IUserService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { instance.Username = dto.Username; instance.Email = dto.Email; instance.IsActive = dto.IsActive; instance.CreatedDate = dto.CreatedDate; instance.ModifiedDate = dto.ModifiedDate; instance.LastConnectDate = dto.LastConnectDate; instance.DomainId = dto.DomainId; instance.LanguageId = dto.LanguageId; instance.MatchId = dto.MatchId; instance.FullName = dto.FullName; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <UserData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <ReferenceData> SaveReferenceBasic(ReferenceData dto) { ArgumentValidator.IsNotNull("dto", dto); FacadeUpdateResult <ReferenceData> result = new FacadeUpdateResult <ReferenceData>(); IReferenceService service = UnitOfWork.GetService <IReferenceService>(); Reference instance = RetrieveOrNew <ReferenceData, Reference, IReferenceService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { instance.Slug = dto.Slug; instance.Title = dto.Title; instance.ThumbnailUrl = dto.ThumbnailUrl; instance.Description = dto.Description; instance.Keywords = dto.Keywords; instance.EnableAds = dto.EnableAds; instance.EnableTopAd = dto.EnableTopAd; instance.ModifiedDate = DateTime.Now; instance.LocationId = dto.LocationId; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <ReferenceData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <ProjectData> SaveTask(TaskDto childDto, object parentId) { ArgumentValidator.IsNotNull("childDto", childDto); FacadeUpdateResult <ProjectData> result = new FacadeUpdateResult <ProjectData>(); IProjectService projectService = UnitOfWork.GetService <IProjectService>(); var projectQuery = projectService.Retrieve(parentId); if (projectQuery.HasResult) { Project project = projectQuery.ToBo <Project>(); Task task = RetrieveOrNewTask(project, childDto.Id); if (task != null) { task.Name = childDto.Name; task.Description = childDto.Description; var saveQuery = projectService.Save(project); result.Merge(saveQuery); result.AttachResult(project.RetrieveData <ProjectData>()); } else { AddError(result.ValidationResult, "TaskCannotBeFound"); } } return(result); }
internal IFacadeUpdateResult <DocumentData> SaveDocument(DocumentDto dto) { ArgumentValidator.IsNotNull("dto", dto); FacadeUpdateResult <DocumentData> result = new FacadeUpdateResult <DocumentData>(); IDocumentService service = UnitOfWork.GetService <IDocumentService>(); Document instance = RetrieveOrNew <DocumentData, Document, IDocumentService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { instance.Name = dto.Name; instance.Description = dto.Description; instance.Notes = dto.Notes; instance.FileName = dto.FileName; instance.Content = dto.Content; instance.Thumbnail = MakeThumbnail(dto.Content); instance.DocTypeId = dto.DocTypeId; instance.IssuedById = dto.IssuedById; instance.IssuedDate = dto.IssuedDate; instance.Extension = dto.Extension; instance.ContentType = GetContentType(dto.Extension); instance.ContentLength = dto.Content.Length; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <DocumentData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <EmployeeData> SaveEmployee(EmployeeDto dto) { ArgumentValidator.IsNotNull("dto", dto); FacadeUpdateResult <EmployeeData> result = new FacadeUpdateResult <EmployeeData>(); IEmployeeService service = UnitOfWork.GetService <IEmployeeService>(); Employee instance = RetrieveOrNew <EmployeeData, Employee, IEmployeeService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { instance.Name = dto.Name; instance.FullName = dto.FullName; instance.JobTitle = dto.JobTitle; instance.AddressLine1 = dto.AddressLine1; instance.AddressLine2 = dto.AddressLine2; instance.Country = dto.Country; instance.CountryState = dto.CountryState; instance.City = dto.City; instance.ZipCode = dto.ZipCode; instance.Phone = dto.Phone; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <EmployeeData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <TransactionData> DeleteTransactionItem(object parentId, object childId) { ArgumentValidator.IsNotNull("parentId", parentId); ArgumentValidator.IsNotNull("childId", childId); FacadeUpdateResult <TransactionData> result = new FacadeUpdateResult <TransactionData>(); ITransactionService service = UnitOfWork.GetService <ITransactionService>(); var query = service.Retrieve(parentId); if (query.HasResult) { Transaction parent = query.ToBo <Transaction>(); TransactionItem child = parent.TransactionItems.SingleOrDefault(o => object.Equals(o.Id, childId)); if (child != null) { parent.TransactionItems.Remove(child); var saveQuery = parent.Save(); result.Merge(saveQuery); result.AttachResult(parent.RetrieveData <TransactionData>()); } else { AddError(result.ValidationResult, "TransactionItemCannotBeFound"); } } else { AddError(result.ValidationResult, "TransactionCannotBeFound"); } return(result); }
internal IFacadeUpdateResult <CustomerData> SaveCustomer(CustomerDto dto) { ArgumentValidator.IsNotNull("dto", dto); FacadeUpdateResult <CustomerData> result = new FacadeUpdateResult <CustomerData>(); ICustomerService service = UnitOfWork.GetService <ICustomerService>(); Customer instance = RetrieveOrNew <CustomerData, Customer, ICustomerService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { instance.Name = dto.Name; instance.Description = dto.Description; instance.AddressLine1 = dto.AddressLine1; instance.AddressLine2 = dto.AddressLine2; instance.Country = dto.Country; instance.CountryState = dto.CountryState; instance.City = dto.City; instance.ZipCode = dto.ZipCode; instance.Phone = dto.Phone; instance.Fax = dto.Fax; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <CustomerData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <TransactionData> SaveTransactionItem(object parentId, TransactionItemDto childDto) { ArgumentValidator.IsNotNull("parentId", parentId); ArgumentValidator.IsNotNull("childDto", childDto); FacadeUpdateResult <TransactionData> result = new FacadeUpdateResult <TransactionData>(); ITransactionService service = UnitOfWork.GetService <ITransactionService>(); var parentQuery = service.Retrieve(parentId); if (parentQuery.HasResult) { Transaction parent = parentQuery.ToBo <Transaction>(); TransactionItem child = RetrieveOrNewTransactionItem(parent, childDto.Id); if (child != null) { child.ItemDescription = childDto.ItemDescription; child.ProductId = childDto.ProductId; child.Quantity = childDto.Quantity; child.UnitPrice = childDto.UnitPrice; child.Amount = childDto.Amount; var saveQuery = service.Save(parent); result.Merge(saveQuery); result.AttachResult(parent.RetrieveData <TransactionData>()); } else { AddError(result.ValidationResult, "TransactionItemCannotBeFound"); } } return(result); }
internal IFacadeUpdateResult <FolderData> SaveFolderLanguage(FolderData dto, object languageId) { ArgumentValidator.IsNotNull("dto", dto); ArgumentValidator.IsNotNull("languageId", languageId); FacadeUpdateResult <FolderData> result = new FacadeUpdateResult <FolderData>(); IFolderService service = UnitOfWork.GetService <IFolderService>(); Folder instance = RetrieveOrNew <FolderData, Folder, IFolderService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { // Check existence of current language FolderLanguage FolderLanguage = instance.FolderLanguages.FirstOrDefault(o => object.Equals(o.LanguageId, languageId)); if (FolderLanguage == null) { FolderLanguage = instance.FolderLanguages.AddNewBo(); FolderLanguage.LanguageId = languageId; } FolderLanguage.Name = dto.Name; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <FolderData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <TransactionData> SaveTransaction(TransactionDto dto) { ArgumentValidator.IsNotNull("dto", dto); FacadeUpdateResult <TransactionData> result = new FacadeUpdateResult <TransactionData>(); ITransactionService service = UnitOfWork.GetService <ITransactionService>(); Transaction instance = RetrieveOrNew <TransactionData, Transaction, ITransactionService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { instance.TransactionNumber = dto.TransactionNumber; instance.CustomerId = dto.CustomerId; instance.ContactId = dto.ContactId; instance.DateSigned = dto.DateSigned; instance.EffectiveDate = dto.EffectiveDate; instance.Amount = dto.Amount; instance.CurrencyId = dto.CurrencyId; instance.Notes = dto.Notes; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <TransactionData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <OpportunityData> SaveOpportunity(OpportunityDto dto) { ArgumentValidator.IsNotNull("dto", dto); FacadeUpdateResult <OpportunityData> result = new FacadeUpdateResult <OpportunityData>(); IOpportunityService service = UnitOfWork.GetService <IOpportunityService>(); Opportunity instance = RetrieveOrNew <OpportunityData, Opportunity, IOpportunityService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { instance.Name = dto.Name; instance.Description = dto.Description; instance.ContactId = dto.ContactId; instance.CustomerId = dto.CustomerId; instance.ProductId = dto.ProductId; instance.EstimateAmount = dto.EstimateAmount; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <OpportunityData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <ContactData> DeleteContactContactMethod(object parentId, object childId) { ArgumentValidator.IsNotNull("parentId", parentId); ArgumentValidator.IsNotNull("childId", childId); FacadeUpdateResult <ContactData> result = new FacadeUpdateResult <ContactData>(); IContactService service = UnitOfWork.GetService <IContactService>(); var query = service.Retrieve(parentId); if (query.HasResult) { Contact parent = query.ToBo <Contact>(); ContactContactMethod child = parent.ContactContactMethods.SingleOrDefault(o => object.Equals(o.Id, childId)); if (child != null) { parent.ContactContactMethods.Remove(child); var saveQuery = parent.Save(); result.Merge(saveQuery); result.AttachResult(parent.RetrieveData <ContactData>()); } else { AddError(result.ValidationResult, "ContactContactMethodCannotBeFound"); } } else { AddError(result.ValidationResult, "ContactCannotBeFound"); } return(result); }
internal IFacadeUpdateResult <NewsData> SaveNews(NewsDto dto) { ArgumentValidator.IsNotNull("dto", dto); FacadeUpdateResult <NewsData> result = new FacadeUpdateResult <NewsData>(); INewsService service = UnitOfWork.GetService <INewsService>(); News instance = RetrieveOrNew <NewsData, News, INewsService>(result.ValidationResult, dto.Id); if (result.IsSuccessful) { instance.Title = dto.Title; instance.Content = dto.Content; instance.IssuedById = dto.IssuedById; instance.IssuedTime = dto.IssuedTime; instance.NewsGroupId = dto.NewsGroupId; instance.CategoryId = dto.CategoryId; var saveQuery = service.Save(instance); result.AttachResult(instance.RetrieveData <NewsData>()); result.Merge(saveQuery); } return(result); }
internal IFacadeUpdateResult <CollectionData> DeleteCollectionItem(object parentId, object childId) { ArgumentValidator.IsNotNull("parentId", parentId); ArgumentValidator.IsNotNull("childId", childId); FacadeUpdateResult <CollectionData> result = new FacadeUpdateResult <CollectionData>(); ICollectionService service = UnitOfWork.GetService <ICollectionService>(); Collection parent = RetrieveOrNew <CollectionData, Collection, ICollectionService>(result.ValidationResult, parentId); if (parent != null) { CollectionItem child = parent.CollectionItems.SingleOrDefault(o => object.Equals(o.Id, childId)); if (child != null) { parent.CollectionItems.Remove(child); var saveQuery = parent.Save(); result.Merge(saveQuery); result.AttachResult(parent.RetrieveData <CollectionData>()); } else { AddError(result.ValidationResult, "CollectionCollectionMethodCannotBeFound"); } } else { AddError(result.ValidationResult, "CollectionCannotBeFound"); } return(result); }