public void AddPublicationInPublisihngHouses(Brochure Brochure, List <string> publisihngHouseIdsExist, List <string> idsNew) { var stringForAdd = new List <string>(); foreach (var idNew in idsNew) { var isPublisihngHouseIdsExist = publisihngHouseIdsExist.Where(x => x == idNew).FirstOrDefault(); if (isPublisihngHouseIdsExist == null) { stringForAdd.Add(idNew); } } foreach (var subString in stringForAdd) { if (subString == Errors.Error.ToString()) { continue; } var publicationInPublisihngHouseRepository = _publicationInPublisihngHouses.Where(x => x.Publication.Id == Brochure.Publication.Id && x.PublishingHouse.Id == subString).FirstOrDefault(); if (publicationInPublisihngHouseRepository != null) { continue; } var publicationInPublisihngHouse = new PublicationInPublisihngHouse(); publicationInPublisihngHouse.Publication = Brochure.Publication; var publishingHouse = _publishingHouses.Where(x => x.Id == subString).FirstOrDefault(); publicationInPublisihngHouse.PublishingHouse = publishingHouse; _publicationInPublisihngHouseRepository.Insert(publicationInPublisihngHouse); _publicationInPublisihngHouseRepository.Save(); } }
/// <summary> /// Xml editor for brochures /// </summary> /// <returns></returns> private List <Brochure> GetBrochures() { List <Brochure> container = new List <Brochure>(); if (!File.Exists(brochurePath)) { XDocument xdoc = new XDocument(); XElement brochures = new XElement("brochures"); xdoc.Add(brochures); xdoc.Save(brochurePath); } XDocument xDoc = XDocument.Load(brochurePath); foreach (XElement brochureElement in xDoc.Element("brochures").Elements("brochure")) { Brochure brochure = new Brochure(); XAttribute idAttr = brochureElement.Attribute("id"); XElement nameEl = brochureElement.Element("name"); XElement authorEl = brochureElement.Element("author"); XElement coverEl = brochureElement.Element("cover"); XElement pagesEl = brochureElement.Element("pages"); if (idAttr != null && nameEl != null && authorEl != null && pagesEl != null && pagesEl != null) { brochure.Id = Int32.Parse(idAttr.Value); brochure.Author = authorEl.Value; brochure.Name = nameEl.Value; brochure.Cover = coverEl.Value; brochure.Pages = Int32.Parse(pagesEl.Value); container.Add(brochure); } } return(container); }
public void DeletePublicationInPublisihngHouses(Brochure Brochure, List <string> publisihngHouseIdsExist, List <string> idsNew) { var stringForDelete = new List <string>(); foreach (var publisihngHouseIdExist in publisihngHouseIdsExist) { var isPublisihngHouseIdsExist = idsNew.Where(x => x == publisihngHouseIdExist).FirstOrDefault(); if (isPublisihngHouseIdsExist == null) { stringForDelete.Add(publisihngHouseIdExist); } } foreach (var subString in stringForDelete) { if (subString == Errors.Error.ToString()) { continue; } var publicationInPublisihngHouses = _publicationInPublisihngHouses.Where(x => x.Publication.Id == Brochure.Publication.Id && x.PublishingHouse.Id == subString).FirstOrDefault(); var publicationInPublisihngHousesSimple = _applicationContext.PublicationInPublisihngHouses.ToList(); _publicationInPublisihngHouseRepository.Delete(publicationInPublisihngHouses); _publicationInPublisihngHouseRepository.Save(); } }
private List <int> Generate() { Brochure brochure = new Brochure((int)nudAllPages.Value, (int)nudRows.Value, (int)nudColumns.Value, chkPageWithSingleCard.Checked); return(brochure.GetPrintingPageNumbers()); }
public BrochureViewModel Get(int?id) { Brochure brochure = _brochureRepository.Get(id.Value); var result = Mapper.Map <Brochure, BrochureViewModel>(brochure); return(result); }
public async Task WhenBrochureHasNonLegacyImages_DoesNothing() { // given var brochure = new Brochure { Id = new Uri(SourceId), Images = { Members = new[] { new Image(), } } }; this.sourceRepository.GetBrochure(Arg.Any <Uri>()) .Returns(Task.FromResult(brochure)); var pdfUploaded = new PdfUploaded { BlobUri = BlobUri, Name = Name, SourceId = SourceId, }; // when await this.functions.Run(pdfUploaded); // then this.imageService.AddedImages.ShouldBe(0); }
public async Task WhenBrochureHasNoPageCount_SetsFromPdf() { // given var brochure = new Brochure { Id = new Uri(SourceId), }; this.sourceRepository.GetBrochure(Arg.Any <Uri>()) .Returns(Task.FromResult(brochure)); this.httpMessageHandler.Expect(BlobUri) .Respond(KnownMimeTypes.Pdf, Resource.AsStream("Pdfs/mb1.pdf")); var pdfUploaded = new PdfUploaded { BlobUri = BlobUri, Name = Name, SourceId = SourceId, }; // when await this.functions.Run(pdfUploaded); // then await this.persistence .Received(1) .SaveBrochure(Arg.Is <Brochure>(b => b.Pages == 9)); }
public IActionResult BrochureToevoegen() { var brochure = new Brochure(); return(View(brochure)); }
public void Update(PutBrochureViewModel brochureView) { Brochure brochure = Mapper.Map <PutBrochureViewModel, Brochure>(brochureView); brochure.PublicationType = PublicationType.Brochure; _brochureRepository.Update(brochure); }
public void UpdateBrochure(BrochureViewModel brochure) { Brochure mappedBrochure = mapper.Map <BrochureViewModel, Brochure>(brochure); db.Brochures.Update(mappedBrochure); db.Save(); }
// // GET: /Brochure/Details/5 public ActionResult Details(int id = 0) { Brochure brochure = db.Brochures.Find(id); Session["BrochureID"] = id; Session["BrochureName"] = brochure.BrochureName; brochure.CategoryList = db.Categories.ToList().Join( db.mappings.ToList(), cat => cat.ID, map => map.CategoryID, (cat, map) => new{ Category = cat, MapCategory = map }) .Where(both => both.MapCategory.BrochureID == id) .Select(both => both.Category).Distinct().ToList(); //brochure.CategoryList=from m in db.Categories if (brochure == null) { return(HttpNotFound()); } ViewBag.BrochureID = id; ViewBag.BrochureName = brochure.BrochureName; ViewBag.returnUrl = Request.Url.AbsoluteUri; return(View(brochure)); }
private void Page_Load(object sender, System.EventArgs e) { // this.warpGrid.AddLinkedRequestTrigger("butAddItem"); if (Session["CustomerID"] == null) { Response.Redirect("Default.aspx"); } else { this.AddKeepAlive(); oMySql = new MySQL(ConnectionType.NonUnique); oCustomer = new Customer(Session["CompanyID"].ToString()); oCustomer.oMySql = oMySql; oCustomer.Find(Session["CustomerID"].ToString()); oCustomerCS = new Customer.CustomerCS(oCustomer.CompanyID, oMySql); oCustomerCS.oMySql = oMySql; oCustomerCS.Find(oCustomer.ID); oBrochure = new Brochure(oCustomer.CompanyID); oBrochure.oMySql = oMySql; txtEarlyBirdDate.Value = DateTime.Today.ToString("MM/dd/yyyy"); txtName.Text = oCustomer.Name; oMySql.Dispose(); } }
public async Task <JsonResult> CreateBrochureFromBrochure(string BrochureID, string BrochureName, string copyFrom) { //string copyFrom = fc["copyFrom"].ToString(); //string copyTo = fc["copyTo"].ToString(); //string returnUrl = fc["returnUrl"].ToString(); // string message = ""; if (ShrdMaster.Instance.checkBrochureID(BrochureID)) { // message = ""; return(Json("0", JsonRequestBehavior.AllowGet)); } Brochure b = new Brochure(); b.BrochureID = BrochureID; b.BrochureName = BrochureName; db.Brochures.Add(b); db.SaveChanges(); //Brochure createdBrochure =(Brochure)db.Brochures.Where(x => x.BrochureID == BrochureID && x.BrochureName == BrochureName); int cpyFrom, cpyto; cpyto = b.ID; int.TryParse(copyFrom, out cpyFrom); //int.TryParse(copyTo, out cpyTo); List <CategoryMapping> map = db.CategoryToBrochureMap.Where(x => x.BrochureID == cpyFrom).ToList(); await ShrdMaster.Instance.CopyBrochure(map, cpyto); //string datatoreturn = copyFrom + "-" + copyTo + "-" + returnUrl; return(Json("1", JsonRequestBehavior.AllowGet)); }
public Brochure CreateBrochure(EntityWrapper <BrochureEntity> source) { var target = new Brochure { Id = this.expander.ExpandAbsolute <Brochure>(new { id = source.Entity.Id }) }; if (source.Entity.Notes != null) { target.Description = source.Entity.Notes; } if (source.Entity.FolderCode != null) { target.Code = source.Entity.FolderCode; } if (source.Entity.FolderName != null) { target.Title = source.Entity.FolderName; } this.CreateImageLinks(target, source); MapSource(target, source.Entity); return(target); }
private static void UpdateEntity(Brochure brochure, BrochureEntity brochureEntity, bool updateFileContents) { brochureEntity.FolderName = brochure.Title; brochureEntity.Notes = brochure.Description; if (brochure.Date.HasValue) { var date = brochure.Date.Value; brochureEntity.Day = (byte)date.Day; brochureEntity.Month = (byte)date.Month; brochureEntity.Year = (byte)date.Year; } else { brochureEntity.Day = null; brochureEntity.Year = brochure.Year; brochureEntity.Month = brochure.Month; } brochureEntity.Pages = brochure.Pages; var validLanguages = brochure.Languages.Where(lang => lang != null).Where(lang => lang.IsValid).Select(lang => lang.Name); brochureEntity.Languages = string.Join(";", validLanguages); if (updateFileContents) { brochureEntity.ContentUrl = brochure.Content.ContentUrl?.ToString(); brochureEntity.ContentSize = brochure.Content.ContentSizeMb; } }
public void Add(PostBrochureViewModel brochureView) { Brochure brochure = Mapper.Map <PostBrochureViewModel, Brochure>(brochureView); brochure.PublicationType = PublicationType.Brochure; _brochureRepository.Add(brochure); }
public void Update(Brochure brochure) { var current = Get(brochure.Id); current.PublishingHouse = context.PublishingHouses.Find(brochure.PublishingHouse?.Id ?? brochure.PublishingHouse_Id); context.Entry(current).CurrentValues.SetValues(brochure); }
public async Task <ActionResult> SelectBrochureTemp(string OptionsProductID, string BrochureID) { try { if (!string.IsNullOrEmpty(OptionsProductID) && !string.IsNullOrEmpty(BrochureID)) { Guid bid = new Guid(BrochureID); Guid opid = new Guid(OptionsProductID); Brochure find = await BrochureRepository.FindAsync(b => b.BrochureID == bid); find.IsTemp = false; find.AddDate = DateTime.Now.ToLocalTime(); find.OptionsProductID = opid; find.BrochureID = new Brochure().BrochureID; Brochure addBro = BrochureRepository.Add(find); if (addBro != null) { bool IsExist = await BrochureRepository.ExistAsync(b => b.OptionsProductID == opid && b.BrochureID != addBro.BrochureID); if (IsExist) { Brochure x = await BrochureRepository.FindAsync(b => b.OptionsProductID == opid && b.BrochureID != addBro.BrochureID); //删除原有的正式宣传册 BrochureRepository.Delete(x); } //更新产品说明链接 string BrochureURL = ConfigurationManager.AppSettings["BrochureURL"].ToString() + opid.ToString(); OptionsProduct findop = await OptionsProductRepository.FindAsync(op => op.OptionsProductID == opid); findop.ProductUrl = BrochureURL; OptionsProductRepository.Update(findop); LogRepository.Add(new EventLog() { Name = Session["LoginedUser"].ToString(), Date = DateTime.Now.ToLocalTime(), Event = "选择宣传册模板作为正式宣传册成功" }); return(Json(new { Success = true })); } } return(Json(new { Success = false })); } catch (Exception ex) { LogRepository.Add(new EventLog() { Name = Session["LoginedUser"].ToString(), Date = DateTime.Now.ToLocalTime(), Event = "选择宣传册模板作为正式宣传册失败" + ex.Message }); return(Json(new { Success = false })); } }
public BrochureViewModel Get(int id) { Brochure brochureFromDB = _brochureRepository.Get(id); var brochure = Mapper.Map <Brochure, BrochureViewModel>(brochureFromDB); return(brochure); }
public int CreateBrochure(BrochureViewModel brochure) { Brochure mappedBrochure = mapper.Map <BrochureViewModel, Brochure>(brochure); var newId = db.Brochures.Create(mappedBrochure); db.Save(); return(newId); }
private void frmOrder_Load(object sender, System.EventArgs e) { this.Text += " - " + this.CompanyID; oBrochure = new Brochure(this.CompanyID); oProduct = new Product(this.CompanyID); oPack = new Pack(this.CompanyID); this.txtBrochureID.Focus(); }
public JsonResult DeleteConfirmed(int id) { Brochure brochure = db.Brochures.Find(id); db.Brochures.Remove(brochure); db.SaveChanges(); return(Json("done", JsonRequestBehavior.AllowGet)); }
public BrochureViewModel Get(int id) { Brochure brochureModel = _unitOfWork.Brochures.Get(id); BrochureViewModel brochureViewModel = Mapper.Map <Brochure, BrochureViewModel>(brochureModel); return(brochureViewModel); }
public int Create(Brochure brochure) { brochure.PublishingHouse = context.PublishingHouses.Find(brochure.PublishingHouse.Id); context.Brochures.Add(brochure); context.SaveChanges(); return(brochure.Id); }
public void Put(PutBrochureView brochure) { Brochure BrochureModel = _brochureRepository.Get(brochure.Id); BrochureModel.Name = brochure.Name; BrochureModel.NumberOfPages = brochure.NumberOfPages; BrochureModel.TypeOfCover = brochure.TypeOfCover; _brochureRepository.Update(BrochureModel); }
public async Task SaveBrochure(Brochure brochure, bool updateFileContents = false) { var id = this.matcher.Match <Brochure>(brochure.Id).Get <int>("id"); var brochureEntity = this.context.Brochures.Find(id); UpdateEntity(brochure, brochureEntity, updateFileContents); await this.context.SaveChangesAsync(); }
private void frmCustomerListing_Load(object sender, EventArgs e) { oCustomer = new Customer(base.CompanyID); oBrochure = new Brochure(base.CompanyID); oPrize = new Prize(base.CompanyID); txtDateFrom.Value = null; txtDateTo.Value = null; }
public async Task Update(Brochure item) { string query = _queryHelper.GenerateUpdateQuery(); using (var db = new SqlConnection(_connectionString)) { await db.ExecuteAsync(query, item); } }
public ActionResult EditBrochure(Brochure brochure, FormCollection formCollection) { if (ModelState.IsValid) { EditAsset(brochure, formCollection); return(RedirectToAction("Index")); } return(RedirectToAction("Index")); }
public async Task <ActionResult> DeleteConfirmed(int id) { Brochure brochure = await db.Brochures.FindAsync(id); db.Brochures.Remove(brochure); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public void Populate() { var brochure = new Brochure { Title = "QuickSnacks DownTown", Description = "Serving all local city folks with quick scrumscious snacks." }; var menu = new Menu { Brochure = brochure, Name = "Today's special Menu", Description = "All your favorite delights" }; var fingerItem = new FingerItem { Name = "Hamlets", Description = "another Pig in a blanket" }; var menuItem = new MenuItem { Menu = menu, FingerItem = fingerItem, Name = "Sausage Rolls", Description = "a.k.a Pig in a blanket" }; var user = new User { FirstName = "John", LastName = "Doe", ActiveToken = null }; var token = new Token { AuthKey = Guid.NewGuid(), User = user }; }