public IActionResult Create(BusView busView, IFormFile inputphoto) { busView.Status = true; string FileNameSave = ""; if (inputphoto != null) { FileNameSave = FileACE.SaveFile(webHostEnvironment, inputphoto, "admin/image"); } busView.Image = FileNameSave; int id = (int)CheckError.ErrorOrther; if (ModelState.IsValid) { id = _IBusrepo.CreateACE(busView); } switch (id) { case (int)CheckError.AlreadyCode: ViewBag.Result = CheckError.AlreadyCode; break; case (int)CheckError.ErrorOrther: ViewBag.Result = CheckError.ErrorOrther; break; default: return(RedirectToAction("index")); } ViewBag.categories = _ICategoryrepo.GetDataACE(); return(View(busView)); }
public IActionResult Edit(BusView busView, IFormFile inputphoto) { busView.Status = true; busView.Active = true; string FileNameSave = "abc.jpg"; if (inputphoto != null) { FileNameSave = FileACE.SaveFile(webHostEnvironment, inputphoto, "admin/image"); FileACE.RemoveFile(webHostEnvironment, $"admin\\image\\{_IBusrepo.GetByIdBus(busView.Id).Image}"); } busView.Image = FileNameSave; int id = (int)CheckError.ErrorOrther; if (ModelState.IsValid) { id = _IBusrepo.UpdateBus(busView); } switch (id) { case (int)CheckError.AlreadyCode: ViewBag.Result = CheckError.AlreadyCode; break; case (int)CheckError.ErrorOrther: ViewBag.Result = CheckError.ErrorOrther; break; default: TempData["ModifySuccess"] = CheckError.Success; return(RedirectToAction("index")); } ViewBag.categories = _ICategoryrepo.GetDataACE(); return(View(busView)); }
public IActionResult Modify(AccountView accountView, IFormFile inputphoto) { accountView.DayCreate = DateTime.Now; accountView.DayEdited = DateTime.Now; accountView.Status = true; string FileNameSave = "dui.jpg"; if (inputphoto != null) { FileNameSave = FileACE.SaveFile(webHostEnvironment, inputphoto, "admin/image"); FileACE.RemoveFile(webHostEnvironment, $"admin\\image\\{accountRepository.GetByIdACE(accountView.Id).Images}"); } accountView.Images = FileNameSave; int id = (int)CheckError.ErrorOrther; if (ModelState.IsValid) { id = accountRepository.ModifyACE(accountView, Convert.ToInt32(User.FindFirst("id").Value)); } switch (id) { case (int)CheckError.AlreadyEmail: ViewBag.Result = CheckError.AlreadyEmail; break; case (int)CheckError.AlreadyPhone: ViewBag.Result = CheckError.AlreadyPhone; break; case (int)CheckError.ErrorOrther: ViewBag.Result = CheckError.ErrorOrther; break; default: TempData["ModifySuccess"] = CheckError.Success; return(RedirectToAction("index")); } ViewBag.StationList = stationRepository.GetDataACE(); return(View(accountView)); }
public IActionResult Create(AccountView accountView, IFormFile inputphoto) { accountView.DayCreate = DateTime.Now; accountView.DayEdited = DateTime.Now; accountView.Status = true; string FileNameSave = "dui.jpg"; if (inputphoto != null) { FileNameSave = FileACE.SaveFile(webHostEnvironment, inputphoto, "admin/image"); } accountView.Images = FileNameSave; int id = (int)CheckError.ErrorOrther; if (ModelState.IsValid) { id = accountRepository.CreateACE(accountView); } switch (id) { case (int)CheckError.AlreadyEmail: ViewBag.Result = CheckError.AlreadyEmail; break; case (int)CheckError.AlreadyPhone: ViewBag.Result = CheckError.AlreadyPhone; break; case (int)CheckError.ErrorOrther: ViewBag.Result = CheckError.ErrorOrther; break; default: return(RedirectToAction("index")); } ViewBag.StationList = stationRepository.GetDataACE(); return(View(accountView)); }
public IActionResult Upload(IFormFile upload) { string filename = FileACE.SaveFile(webHostEnvironment, upload, "/admin/image"); return(Json("/admin/image/" + filename)); }