public async Task <IActionResult> PostUploadProfilePicture(List <IFormFile> files) { try { var fileName = await _netcoreService.UploadFile(files, _env); //try to update the user profile pict ApplicationUser appUser = await _userManager.GetUserAsync(User); appUser.profilePictureUrl = "/uploads/" + fileName; _context.Update(appUser); _context.SaveChanges(); return(Ok(fileName)); } catch (Exception ex) { return(StatusCode(500, new { message = ex.Message })); } }
public async Task <IActionResult> Edit(string id, [Bind("leadId,leadName,description,street1,street2,city,province,country,isQualified,isConverted,channelId,customerId,accountExecutiveId,HasChild,createdAt")] Lead lead) { if (id != lead.leadId) { return(NotFound()); } if (ModelState.IsValid) { try { if (!lead.isQualified) { lead.isConverted = false; } if (!String.IsNullOrEmpty(lead.customerId)) { lead.isConverted = true; lead.isQualified = true; } _context.Update(lead); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LeadExists(lead.leadId)) { return(NotFound()); } else { throw; } } //convert to customer, only if customerId is still empty and already qualified if (lead.isQualified && lead.isConverted && String.IsNullOrEmpty(lead.customerId)) { Customer cust = new Customer(); cust.city = lead.city; cust.country = lead.country; cust.customerName = lead.leadName; cust.description = lead.description; cust.province = lead.province; cust.street1 = lead.street1; cust.street2 = lead.street2; _context.Customer.Add(cust); _context.SaveChanges(); lead.customerId = cust.customerId; _context.Update(lead); _context.SaveChanges(); } return(RedirectToAction(nameof(Index))); } ViewData["accountExecutiveId"] = new SelectList(_context.AccountExecutive, "accountExecutiveId", "accountExecutiveName", lead.accountExecutiveId); ViewData["channelId"] = new SelectList(_context.Channel, "channelId", "channelName", lead.channelId); return(View(lead)); }