public async Task <IActionResult> UpdateAccountVendor(AccountVendor vendor) { _dbContext.AccountVendors.Update(vendor); await _dbContext.SaveChangesAsync(); return(Ok(vendor)); }
public async Task <IActionResult> DeleteAccountVendor(long id) { AccountVendor vendor = await _dbContext.AccountVendors.FirstOrDefaultAsync(av => av.Id == id); if (vendor is null) { return(NotFound()); } vendor.Status = GenericStatus.Inactive; _dbContext.AccountVendors.Update(vendor); await _dbContext.SaveChangesAsync(); return(Ok()); }
public IActionResult Register(AccountVendor accountVendor, IFormFile logo) { try { if (accountVendor.Email != null && Exists(accountVendor.Email)) { ModelState.AddModelError("Username", sharedLocalizer["Username_already_exists"]); } if (accountVendor.Password != null && !PasswordHelper.IsValidPassword(accountVendor.Password)) { ModelState.AddModelError("Password", "Invalid Password"); } if (logo != null && logo.Length > 0 && !logo.ContentType.Contains("image")) { ViewBag.errorPhoto = sharedLocalizer["Photo_Invalid"]; return(View("Register", accountVendor)); } if (ModelState.IsValid) { accountVendor.Password = BCrypt.Net.BCrypt.HashPassword(accountVendor.Password); accountVendor.Status = true; //if (logo != null && logo.Length > 0 && logo.ContentType.Contains("image")) //{ // var fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + Path.GetFileName(logo.FileName); // var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/user/images", fileName); // var stream = new FileStream(path, FileMode.Create); // logo.CopyTo(stream); // accountVendor.Logo = fileName; //} //else //{ // accountVendor.Logo = "no-logo.jpg"; //} ocmde.AccountVendors.Add(accountVendor); // Add Package Trial to new vendor //var membership = ocmde.MemberShips.Find(MemberShipHelper.TrialPackage); //MemberShipVendor memberShipVendor = new MemberShipVendor() //{ // MemerShipId = membership.Id, // VendorId = vendor.Id, // Price = membership.Price, // StartDate = DateTime.Now, // EndDate = DateTime.Now.AddMonths(membership.Month) //}; //ocmde.MemberShipVendors.Add(memberShipVendor); ocmde.SaveChanges(); ocmde.SaveChanges(); return(RedirectToAction("Index", "Login", new { Area = "vendorpanel" })); } return(View("Register", accountVendor)); } catch (Exception e) { throw; } }