public void Add(TourUpdate tourUpdate) { // var category = _categoryRepo.All.Where(a => a.Id == tourUpdate.Category_Id).FirstOrDefault(); var categories = _categoryRepo.All.Where(a => tourUpdate.SelectedCategories.Contains(a.Id)); var tour = new Tour { Code = tourUpdate.Code, Name = tourUpdate.Name, Permalink = tourUpdate.Permalink, AvailabilityStatusId = tourUpdate.AvailabilityStatusId, TourTypeId = tourUpdate.TourTypeId, IsPublished = tourUpdate.IsPublished, LengthDescription = tourUpdate.LengthDescription, DepartureCity = tourUpdate.DepartureCity, ReturningCity = tourUpdate.ReturningCity, MailingListEmailName = tourUpdate.MailingListEmailName, MailingListUrl = tourUpdate.MailingListUrl, MailingListID = tourUpdate.MailingListID, SampleDocumentURL = tourUpdate.SampleDocumentURL }; SEOTool SEOTool = new Core.Domain.SEOTool(); SEOTool.FocusKeyword = tourUpdate.FocusKeyword; SEOTool.MetaDescription = tourUpdate.MetaDescription; SEOTool.SEOTitle = tourUpdate.SEOTitle; tour.SEOTools = new List<Core.Domain.SEOTool>(); tour.SEOTools.Add(SEOTool); tour.Categories = new System.Collections.Generic.List<Category>(); tour.Categories.AddRange(categories.ToList()); _tourRepo.Add(tour); }
public void Add(TourUpdate tourUpdate) { // var category = _categoryRepo.All.Where(a => a.Id == tourUpdate.Category_Id).FirstOrDefault(); var categories = _categoryRepo.All.Where(a => tourUpdate.SelectedCategories.Contains(a.Id)); var tour = new Tour { Code = tourUpdate.Code, Name = tourUpdate.Name, Permalink = tourUpdate.Permalink, AvailabilityStatusId = tourUpdate.AvailabilityStatusId, TourTypeId = tourUpdate.TourTypeId, IsPublished = tourUpdate.IsPublished, LengthDescription = tourUpdate.LengthDescription, DepartureCity = tourUpdate.DepartureCity, ReturningCity = tourUpdate.ReturningCity, MailingListEmailName = tourUpdate.MailingListEmailName, MailingListUrl = tourUpdate.MailingListUrl, MailingListID = tourUpdate.MailingListID, SampleDocumentURL = tourUpdate.SampleDocumentURL }; SEOTool SEOTool = new Core.Domain.SEOTool(); SEOTool.FocusKeyword = tourUpdate.FocusKeyword; SEOTool.MetaDescription = tourUpdate.MetaDescription; SEOTool.SEOTitle = tourUpdate.SEOTitle; tour.SEOTools = new List <Core.Domain.SEOTool>(); tour.SEOTools.Add(SEOTool); tour.Categories = new System.Collections.Generic.List <Category>(); tour.Categories.AddRange(categories.ToList()); _tourRepo.Add(tour); }
public void Update(TourUpdate tourUpdate) { var categories = _categoryRepo.All.Where(a => tourUpdate.SelectedCategories.Contains(a.Id)); var tour = _tourRepo.Find(tourUpdate.Id); tour.Code = tourUpdate.Code; tour.Name = tourUpdate.Name; tour.Permalink = tourUpdate.Permalink; tour.AvailabilityStatusId = tourUpdate.AvailabilityStatusId; tour.TourTypeId = tourUpdate.TourTypeId; tour.IsPublished = tourUpdate.IsPublished; tour.LengthDescription = tourUpdate.LengthDescription; tour.DepartureCity = tourUpdate.DepartureCity; tour.ReturningCity = tourUpdate.ReturningCity; tour.MailingListEmailName = tourUpdate.MailingListEmailName; tour.MailingListUrl = tourUpdate.MailingListUrl; tour.MailingListID = tourUpdate.MailingListID; tour.SampleDocumentURL = tourUpdate.SampleDocumentURL; SEOTool SEOTool = null; if (tour.SEOTools != null && tour.SEOTools.Count() > 0) { SEOTool = tour.SEOTools.First(); } else { SEOTool = new Core.Domain.SEOTool(); tour.SEOTools = new List <Core.Domain.SEOTool>(); tour.SEOTools.Add(SEOTool); } SEOTool.FocusKeyword = tourUpdate.FocusKeyword; SEOTool.MetaDescription = tourUpdate.MetaDescription; SEOTool.SEOTitle = tourUpdate.SEOTitle; List <Category> exixtingCategories = tour.Categories.ToList(); foreach (Category c in exixtingCategories) { tour.Categories.Remove(c); } //tour.Categories = null; tour.Categories = new System.Collections.Generic.List <Category>(); tour.Categories.AddRange(categories.ToList()); _tourRepo.Update(tour); }
public void Update(TourUpdate tourUpdate) { var categories = _categoryRepo.All.Where(a => tourUpdate.SelectedCategories.Contains(a.Id)); var tour = _tourRepo.Find(tourUpdate.Id); tour.Code = tourUpdate.Code; tour.Name = tourUpdate.Name; tour.Permalink = tourUpdate.Permalink; tour.AvailabilityStatusId = tourUpdate.AvailabilityStatusId; tour.TourTypeId = tourUpdate.TourTypeId; tour.IsPublished = tourUpdate.IsPublished; tour.LengthDescription = tourUpdate.LengthDescription; tour.DepartureCity = tourUpdate.DepartureCity; tour.ReturningCity = tourUpdate.ReturningCity; tour.MailingListEmailName = tourUpdate.MailingListEmailName; tour.MailingListUrl = tourUpdate.MailingListUrl; tour.MailingListID = tourUpdate.MailingListID; tour.SampleDocumentURL = tourUpdate.SampleDocumentURL; SEOTool SEOTool = null; if (tour.SEOTools != null && tour.SEOTools.Count() > 0) SEOTool = tour.SEOTools.First(); else { SEOTool = new Core.Domain.SEOTool(); tour.SEOTools = new List<Core.Domain.SEOTool>(); tour.SEOTools.Add(SEOTool); } SEOTool.FocusKeyword = tourUpdate.FocusKeyword; SEOTool.MetaDescription = tourUpdate.MetaDescription; SEOTool.SEOTitle = tourUpdate.SEOTitle; List<Category> exixtingCategories = tour.Categories.ToList(); foreach (Category c in exixtingCategories) tour.Categories.Remove(c); //tour.Categories = null; tour.Categories = new System.Collections.Generic.List<Category>(); tour.Categories.AddRange(categories.ToList()); _tourRepo.Update(tour); }