public async Task <IActionResult> PutLead(string id, Lead lead) { if (id != lead.Id) { return(BadRequest()); } var company = await _context.Companies.FirstOrDefaultAsync(c => c.Id == lead.CompanyId); company.ContactId = lead.Id; _context.Entry(lead).State = EntityState.Modified; _context.Entry(company).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LeadExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutProduct(string id, Product product) { if (id != product.Id) { return(BadRequest()); } _context.Entry(product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCompany(string id, Company company) { if (id != company.Id) { return(BadRequest()); } _context.Entry(company).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CompanyExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,Title,Description")] Product product) { if (ModelState.IsValid) { _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(product)); }
public async Task <IActionResult> Create([Bind("Id,Name,Address,RefLeadId")] Company company) { if (ModelState.IsValid) { _context.Add(company); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["RefLeadId"] = new SelectList(_context.Leads, "Id", "FullName", company.ContactId); return(View(company)); }
public async Task <IActionResult> Create([Bind("Id,OwnerId,LeadId,ProductId,CreationDate,EstimatedCloseDate,Comments,Status,Confidence")] Opportunity opportunity) { if (ModelState.IsValid) { _context.Add(opportunity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["LeadId"] = new SelectList(_context.Leads, "Id", "FullName", opportunity.LeadId); ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Title", opportunity.ProductId); ViewData["Confidence"] = new SelectList((IEnumerable)OpportunityConfidence.AllConfidenceDisplay, "Key", "Value", opportunity.Confidence); ViewData["Status"] = new SelectList((IEnumerable)OpportunityStatus.AllStatusDisplay, "Key", "Value", opportunity.Status); return(View(opportunity)); }
public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,PhoneNumber,Email,Address,CompanyId,Gender")] Lead lead) { if (ModelState.IsValid) { _context.Add(lead); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CompanyId"] = new SelectList(_context.Companies, "Id", "Name", lead.CompanyId); var leadGender = new LeadGender(); ViewData["GenderName"] = new SelectList((IEnumerable)leadGender.AllGender, "Key", "Value"); return(View(lead)); }
public async Task <IActionResult> DeleteConfirmed(string id) { var user = await _context.Set <ApplicationUser>().FindAsync(id); _context.Set <ApplicationUser>().Remove(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }