public ActionResult Index(ProposalModel model) { List <OptionModel> lst = new List <OptionModel>(); foreach (var item in model.SelectedOptions) { lst.Add(new OptionModel { IdOption = Convert.ToInt32(item) }); } VotesModel vote = new VotesModel { Email = ((UserModel)Session["User"]).Email, Options = lst, ContracEthereumProposal = Session["propId"].ToString() }; ProposalBussiness propBuss = new ProposalBussiness(); bool resp = propBuss.DoVote(vote); //save if (resp) { return(RedirectToAction("Proposal", "ProposalList")); } return(RedirectToAction("Proposal", "ProposalList")); }
public static PolicyModel PromoteProposalToPolicy(ProposalModel proposal, string policyApprover) { var proposalToBePromoted = Proposals.FirstOrDefault(p => p.ProposalId == proposal.ProposalId); if (proposalToBePromoted != null) { var newPolicy = new PolicyModel { PolicyId = (++policyCounter), QuoteId = proposalToBePromoted.QuoteId, CarPrice = proposalToBePromoted.CarPrice, VehicleType = proposalToBePromoted.VehicleType, FromDate = proposalToBePromoted.FromDate, ToDate = proposalToBePromoted.ToDate, ApproximatePremiumAmount = proposalToBePromoted.ApproximatePremiumAmount, Issuer = proposalToBePromoted.Issuer, ProposalInitiator = policyApprover, PolicyApprover = policyApprover }; Proposals.Remove(proposalToBePromoted); Policies.Add(newPolicy); return(newPolicy); } return(null); }
public ActionResult Edit(ProposalModel model) { try { User user = UserRepo.GetByUsername(User.Identity.Name); Proposal proposal = ProposalService.GetProposalById(model.ProposalId); if (proposal == null) { return(HttpNotFound()); } if (proposal.User.Equals(user) || user.IsAdministrator()) { proposal.Show.Name = model.Name; proposal.Show.Description = model.Description; return(RedirectToAction("Index")); } return(new HttpStatusCodeResult(( int )HttpStatusCode.Unauthorized)); } catch { return(View()); } }
// GET: Votes public ActionResult Index(string id) { Session["propId"] = id; UserModel user = (UserModel)Session["User"]; if (user == null) { return(RedirectToAction("Index", "Home")); } else { ProposalFilter Filtro = new ProposalFilter(); Filtro.Email = user.Email; // Filtro.TypeVoting = 0; ProposalBussiness ProposalLogic = new ProposalBussiness(); List <ProposalModel> ListProposal = new List <ProposalModel>(); ListProposal = ProposalLogic.SearchProposalByUser(Filtro); ProposalModel currentProposal = ListProposal.Where(x => x.ContracEthereumProposal == id).FirstOrDefault(); ViewBag.UserEmail = user.Email; return(View(currentProposal)); } }
public IActionResult Submit(ProposalViewModel model) { if (ModelState.IsValid) { try { model.Success = ModelState.IsValid; var item = new ProposalModel { ConferenceName = model.ConferenceName, EndDate = model.EndDate, Region = model.Region, Website = model.Website, CreatedOn = DateTime.UtcNow }; m_worker.AddProposal(item); } catch (Exception ex) { model.Success = false; m_telemetry.TrackException(ex); } } model.Empty = false; model.Region = string.Concat(model.Region, " selected"); return(View("Index", model)); }
public ActionResult Checkout(ProposalModel model) { string apiKey = ConfigurationManager.AppSettings["SendGrid.Key"]; SendGrid.SendGridAPIClient client = new SendGrid.SendGridAPIClient(apiKey); SendGrid.Helpers.Mail.Email from = new SendGrid.Helpers.Mail.Email("*****@*****.**"); string subject = "Couture Events: New Client!"; SendGrid.Helpers.Mail.Email to = new SendGrid.Helpers.Mail.Email("*****@*****.**"); Content content = new Content("text/html", " "); Mail mail = new Mail(from, subject, to, content); mail.TemplateId = "13a5ec2f-0260-4134-a3a2-aeacbe6882ec"; mail.Personalization[0].AddSubstitution("-brideName-", model.Customer.BrideFirstName + " " + model.Customer.BrideLastName); mail.Personalization[0].AddSubstitution("-groomName-", model.Customer.GroomFirstName + " " + model.Customer.GroomLastName); mail.Personalization[0].AddSubstitution("-phoneNumber-", model.Customer.PhoneNumber); mail.Personalization[0].AddSubstitution("-email-", model.Customer.Email); mail.Personalization[0].AddSubstitution("-weddingDate-", model.Customer.WeddingDate.ToString()); mail.Personalization[0].AddSubstitution("-numberOfGuests-", model.Customer.NumberOfGuests.ToString()); mail.Personalization[0].AddSubstitution("-serviceName-", model.Service.Name); mail.Personalization[0].AddSubstitution("-address-", model.Customer.Address); mail.Personalization[0].AddSubstitution("-groomsmen-", model.Customer.NumberOfGroomsmen.ToString()); mail.Personalization[0].AddSubstitution("-serviceName-", model.Customer.NumberOfBridesmaids.ToString()); client.client.mail.send.post(requestBody: mail.Get()); return(RedirectToAction("Index", "Home")); }
public IActionResult Add([FromBody] ProposalModel model) { var addedProposal = proposalRepo.Add(model); return(CreatedAtRoute("GetById", new { id = addedProposal.Id }, addedProposal)); }
public async Task <int> Add(ProposalModel model) { var entity = EntityModelAdapter.FromProposalModelToProposal(model); _dbContext.Proposals.Add(entity); return(await _dbContext.SaveChangesAsync()); }
private static IEnumerable <PassengerDto> BuildPassengers(ProposalModel proposalDto) { var passengers = new List <PassengerDto>(); if (proposalDto.Passenger1 != null) { passengers.Add(BuildPassenger(proposalDto.Passenger1)); } if (proposalDto.Passenger2 != null) { passengers.Add(BuildPassenger(proposalDto.Passenger2)); } if (proposalDto.Passenger3 != null) { passengers.Add(BuildPassenger(proposalDto.Passenger3)); } if (proposalDto.Passenger4 != null) { passengers.Add(BuildPassenger(proposalDto.Passenger4)); } return(passengers); }
public async Task <IActionResult> EditProposal(string id, ProposalModel model) { var map = await MapModel.GetAsync(AppSettings.DefaultRepo); var existing = map.Proposals?.FirstOrDefault(i => i.Id == id); if (existing != null) { existing.Title = model.Title; using (await LockingService.LockAsync()) { await map.SaveAsync(); await BaseContentsModel.SaveContentsAsync(id, AppSettings.DefaultRepo, model.Contents); await ChangesService.Get(AppSettings.DefaultRepo).PushChangesAsync(); } } dynamic parameters = new ExpandoObject(); parameters.id = id; return(RedirectToAction(nameof(ViewProposal), parameters)); }
public async Task <IActionResult> CreateProposal(ProposalModel model) { var map = await MapModel.GetAsync(AppSettings.DefaultRepo); var id = Guid.NewGuid().ToString(); if (map.Proposals == null) { map.Proposals = new List <MapProposalModel>(); } map.Proposals.Add(new MapProposalModel() { Id = id, Title = model.Title }); using (await LockingService.LockAsync()) { await map.SaveAsync(); await BaseContentsModel.SaveContentsAsync(id, AppSettings.DefaultRepo, model.Contents); await ChangesService.Get(AppSettings.DefaultRepo).PushChangesAsync(); } dynamic parameters = new ExpandoObject(); parameters.id = id; return(RedirectToAction(nameof(ViewProposal), parameters)); }
public Task <int> Add(ProposalModel model) { var entity = Proposal.FromModel(model); dbContext.Proposals.Add(entity); return(dbContext.SaveChangesAsync()); }
public ActionResult Upload(HttpPostedFileBase file) { ProposalModel proposal = (ProposalModel)Session["Proposal"]; if (file == null) { ViewBag.Error = "No selecciono un archivo"; return(View("RegisterUserProposal", null)); } string archivo = (DateTime.Now.ToString("yyyyMMddHHmmss") + "-" + file.FileName).ToLower(); string ruta = Server.MapPath("~/Files/" + archivo); file.SaveAs(Server.MapPath("~/Files/" + archivo)); if (RegistroMasivo(ruta, ((ProposalModel)Session["Proposal"]).ContracEthereumProposal, ((ProposalModel)Session["Proposal"]).ProposalName)) { ViewBag.Success = "Se enviaron las invitaciones con éxito."; ProposalBussiness ProposalLogic = new ProposalBussiness(); ProposalFilter Filtro = new ProposalFilter(); UserModel user = (UserModel)Session["User"]; Filtro.Email = user.Email; Filtro.QuestionType = null; List <ProposalModel> ListProposal = new List <ProposalModel>(); ListProposal = ProposalLogic.SearchProposalByUser(Filtro); return(View("ProposalList", ListProposal)); } else { ViewBag.Error = "Hay Correos Invalidos"; return(View("RegisterUserProposal", null)); } // return View("ProposalList"); }
public static ProposalModel PromoteQuoteToProposal(QuoteModel quote, string proposalInitiator) { var quoteToBePromoted = Quotes.FirstOrDefault(q => q.QuoteId == quote.QuoteId); if (quoteToBePromoted != null) { var newProposal = new ProposalModel { ProposalId = (++proposalCounter), QuoteId = quoteToBePromoted.QuoteId, CarPrice = quoteToBePromoted.CarPrice, VehicleType = quoteToBePromoted.VehicleType, FromDate = quoteToBePromoted.FromDate, ToDate = quoteToBePromoted.ToDate, ApproximatePremiumAmount = quoteToBePromoted.ApproximatePremiumAmount, Issuer = quoteToBePromoted.Issuer, ProposalInitiator = proposalInitiator }; Quotes.Remove(quoteToBePromoted); Proposals.Add(newProposal); return(newProposal); } return(null); }
public async Task <IActionResult> Add(ProposalModel model) { if (ModelState.IsValid) { await proposalService.Add(model); } return(RedirectToAction("Index", new { conferenceId = protector.Protect(model.ConferenceId.ToString()) })); }
public IActionResult AddProposal(ProposalModel proposal) { if (ModelState.IsValid) { proposalRepo.Add(proposal); } return(RedirectToAction("Index", new { conferenceId = _dataProtector.Protect(proposal.ConferenceId.ToString()) })); }
public async Task <IActionResult> AddProposal(ProposalModel proposal) { if (ModelState.IsValid) { await proposalService.Add(proposal); } return(RedirectToAction("Index", new { conferenceId = proposal.ConferenceId })); }
public IActionResult AddProposal(ProposalModel proposal) { if (ModelState.IsValid) { proposalRepo.Add(proposal); } return(RedirectToAction("Index", new { conferenceId = proposal.ConferenceId })); }
public async Task <IActionResult> EditProposal(ProposalModel proposal) { if (await authorizationService.AuthorizeAsync(User, proposal, "ProposalEditPolicy")) { return(View()); } return(RedirectToAction("AccessDenied", "Account")); }
public async Task <ProposalModel> Add(ProposalModel model) { return(await Task.Run(async() => { HttpResponseMessage message = await this._client.PostAsJsonAsync("v1/Proposal", model).ConfigureAwait(false); return await message.Content.ReadAsAsync <ProposalModel>(); }).ConfigureAwait(false)); }
public Task <ProposalModel> Approve(int id) { return(Task.Run(() => { ProposalModel proposal = proposals.First(p => p.Id == id); proposal.Approved = true; return proposal; })); }
public IActionResult AddProposal(string conferenceId) { ViewBag.Title = "Speaker - Add Proposal"; var model = new ProposalModel { ConferenceId = int.Parse(protector.Unprotect(conferenceId)) }; return(View(model)); }
public async Task <IActionResult> Add(ProposalModel model) { if (this.ModelState.IsValid) { await this._service.Add(model).ConfigureAwait(false); } return(RedirectToAction("Index", new { conferenceId = model.ConferenceId })); }
public Task <ProposalModel> Approve(int proposalId) { return(Task.Run(() => { ProposalModel proposal = _proposals.FirstOrDefault(p => p.Id == proposalId); proposal.Approved = true; return proposal; })); }
public async Task <int> Edit(ProposalModel model) { var proposal = await dbContext.Proposals.FirstAsync(p => p.Id == model.Id); proposal.Speaker = model.Speaker; proposal.Title = model.Title; dbContext.Proposals.Update(proposal); return(await dbContext.SaveChangesAsync()); }
public void AddProposal(ProposalModel item) { lock (m_sync) { m_cache.Remove("Proposals"); m_context.Proposals.Add(item); m_context.SaveChanges(); } }
public ActionResult Create([Bind(Include = "Id,ProposalName,ProposalDescriptionUrl,PaymentDate,NumberOfPayments,PaymentAddress,PaymentAmount")] ProposalModel proposalModel) { if (ModelState.IsValid) { return(RedirectToAction("Index")); } return(View(proposalModel)); }
public Task <ProposalModel> Add(ProposalModel model) { return(Task.Run(() => { model.Id = _proposals.Max(c => c.Id) + 1; _proposals.Add(model); return model; })); }
public async Task <IActionResult> Add(ProposalModel model) { ProposalModel addedModel = null; addedModel = await this._repository.Add(model).ConfigureAwait(false); return(addedModel != null ? await Task.FromResult <IActionResult>(CreatedAtRoute("GetById", new { id = addedModel.Id })) : await Task.FromResult <IActionResult>(NoContent())); }
public bool DeleteProposal(ProposalModel proposal) { bool isSuccess; using (ProposalDataAccess proposalDataAccess = new ProposalDataAccess()) { isSuccess = proposalDataAccess.DeleteProposal(proposal); } return(isSuccess); }