public virtual ActionResult Shrani(DarilniBonUstvariModel model) { if (!ModelState.IsValid) { model.Vrsta = _boniService.VrstaBona(model.VrstaBonaId); return View("Ustvari", model); } Bon bon = null; bool novBon = model.BonId == 0; if (novBon) { bon = new Bon() { Guid = Guid.NewGuid(), Vneseno = DateTime.Now, Status = StatusBona.Narocen, VrstaBonaId = model.VrstaBonaId }; } else { bon = _boniService.Bon(model.BonId); } model.Bon(ref bon); if (bon.VeljaDo == null && bon.VrstaBona != null && bon.VrstaBona.VeljaDni != null) { bon.VeljaDo = bon.Vneseno.AddDays(bon.VrstaBona.VeljaDni.Value); } if (bon.BonId == 0) _boniService.Add(bon); _boniService.SaveChanges(); if (System.Web.HttpContext.Current.UserIsDataTrusted()) { return Redirect("~/DarilniBon/Boni"); } // Reload to get the data gererated by the database bon = _boniService.Bon(bon.Guid); if (novBon) { // Send email notofication to the user _transactionalMailSendingService.SendMail( model.NarocnikEmail, string.Format("{0} {1}", model.NarocnikIme, model.NarocnikPriimek).Trim(), "MailBonNarocen", System.Web.HttpContext.Current.Language(), bon ); } model = new DarilniBonUstvariModel(bon); return View("BonNarocen", model); }
public virtual ActionResult Ustvari(int id) { var vrstaBona = _boniService.VrstaBona(id); var model = new DarilniBonUstvariModel() { KodaBona = (new PortalShared.CryptoUtils()).GeneratePassword(6), Besedilo = vrstaBona.Ime, VeljaZa = vrstaBona.VeljaZa, Navodila = vrstaBona.Navodilo, SlikaUrl = vrstaBona.SlikaUrl, CssClass = vrstaBona.CssClass, VeljaDo = vrstaBona.VeljaDo ?? (DateTime.Now.AddDays(vrstaBona.VeljaDni != null ? vrstaBona.VeljaDni.Value : 180)), Cena = vrstaBona.Cena, Vrsta = vrstaBona, VrstaBonaId = vrstaBona.VrstaBonaId }; return View(model); }
public virtual ActionResult Uredi(int id) { var model = new DarilniBonUstvariModel(_boniService.Bon(id)); model.Vrsta = _boniService.VrstaBona(model.VrstaBonaId); return View("Ustvari", model); }