public virtual async Task <ActionResult> DeleteUser(DeleteUserProfileViewModel deleteUser) { if (deleteUser.StatusDelete) { var userAdmin = await _userManager.FindByIdAsync(deleteUser.Id); var result = await _userManager.DeleteAsync(userAdmin); if (result.Succeeded) { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccsessDelete), Status = AlertMode.success })); } else { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailDelete), Status = AlertMode.warning })); } } else { return(null); } }
public virtual async Task <ActionResult> SendEmail(SendEmailProfileViewModel sendEmail) { try { string Messagedate = ConvertDate.PerssionDate(DateTime.Now); string Explainbody; using (var reader = new StreamReader(Server.MapPath("~/EmailConfiguration/TemplateEmail/_AlertModerators.txt"))) { Explainbody = reader.ReadToEnd(); } string resultBody = string.Format(Explainbody, string.Concat(sendEmail.Name + " " + sendEmail.Family), sendEmail.Subject, sendEmail.Explain.Replace("\r\n", "<br />"), Messagedate); await _userManager.SendEmailAsync(sendEmail.Id, sendEmail.Subject, resultBody); return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccessSendEmail), Status = AlertMode.success })); } catch { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailSendEmail), Status = AlertMode.warning })); } }
public virtual async Task <ActionResult> ChangePassword(ChangePasswordViewModel model) { if (!ModelState.IsValid) { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.Invalid), Status = AlertMode.warning })); } var result = await _userManager.ChangePasswordAsync(User.Identity.GetUserId <int>(), model.OldPassword, model.NewPassword); if (result.Succeeded) { var user = await _userManager.FindByIdAsync(User.Identity.GetUserId <int>()); if (user != null) { await signInAsync(user, isPersistent : false); } return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccessChangePassword), Status = AlertMode.success })); } else { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.ChangePasswordError), Status = AlertMode.warning })); } }
public virtual ActionResult SendComment(int Id, string ExplainComment) { var productId = _commentService.GetProductId(Id); var product = _productService.GetById(productId); product.ModifiedDate = DateTime.Now; _productService.Update(product); var comment = new Comment() { User_Id = User.Identity.GetUserId <int>(), DateTimeComment = DateTime.Now, ReadStatus = true, Explain = ExplainComment.Replace("\r\n", "<br />"), Product_Id = Id }; _commentService.Create(comment); if (_unitOfWork.SaveAllChanges() > 0) { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccessSendComment), Status = AlertMode.success })); } else { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailSendComment), Status = AlertMode.warning })); } }
public virtual ActionResult CreateSlider(ShowSliderViewModel sliderViewModel) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { string fileName = string.Empty; using (var img = Image.FromStream(file.InputStream)) { fileName = TODO.CheckExistFile(Server.MapPath("~/Content/Images/Slider/"), file.FileName); TODO.UploadImage(img, new Size(900, 350), Server.MapPath("~/Content/Images/Slider/"), fileName); } var slider = new Slider { Address = sliderViewModel.AddressSlider, Explain = sliderViewModel.ExplainSlider, Image = fileName, Title = sliderViewModel.TitleSlider }; _sliderService.Create(slider); if (_unitOfWork.SaveAllChanges() > 0) { TempData["createSlider"] = Helperalert.alert(new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccsessInsert), Status = AlertMode.success }); return(RedirectToAction(actionName: MVC.admin.Slider.ActionNames.CreateSlider)); } else { TempData["createSlider"] = Helperalert.alert(new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailInsert), Status = AlertMode.warning }); } } return(View()); }
public virtual ActionResult DeleteIPDanger(string IPAddress) { var list = _elmahService.GetAllByIP(IPAddress); _unitOfWork.RemoveRange <ElmahModel>(list); _blockService.Create(new BlockModel { Date = DateTime.Now, IP = IPAddress }); if (_unitOfWork.SaveAllChanges() > 0) { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccsessInsert), Status = AlertMode.success })); } else { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailInsert), Status = AlertMode.warning })); } }
public virtual ActionResult SendComment(DetailsProductShowViewModel model) { var userId = User.Identity.GetUserId <int>(); var product_Id = model.ProductShowViewModel.Id; if (_productService.IsExistById(product_Id)) { var comment = new Comment() { User_Id = userId, DateTimeComment = DateTime.Now, DisplayStatus = false, Explain = model.SendCommentViewModel.Explain.Replace("\r\n", "<br />").ToSafeHtml(), Product_Id = product_Id }; _commentService.Create(comment); if (_unitOfWork.SaveAllChanges() > 0) { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccessSendComment), Status = AlertMode.success })); } else { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailSendComment), Status = AlertMode.warning })); } } else { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailSendComment), Status = AlertMode.warning })); } }
public virtual ActionResult UpdateCategory(CategoryEditViewModel model) { var category = new Category(); if (model.Parent_Id > 0) { var parentCategory = _categoryService.GetById(model.Parent_Id); category.Parent = parentCategory; } else { category.Parent = null; } category.Id = model.Id; category.Name = model.Name; _categoryService.Update(category); if (_unitOfWork.SaveAllChanges() > 0) { return(RedirectToAction(actionName: MVC.admin.Category.ActionNames.DetailsCategory, routeValues: new { Id = model.Id })); } else { TempData["updateCategory"] = Helperalert.alert(new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.DuplicateName), Status = AlertMode.info }); return(RedirectToAction(actionName: MVC.admin.Category.ActionNames.UpdateCategory, routeValues: new { Id = model.Id })); } }
public virtual PartialViewResult CreateCategory(CategoryAddViewModel model) { if (!ModelState.IsValid) { return(PartialView(viewName: MVC.admin.Shared.Views._ValidationSummery)); } var category = new Category(); if (model.Parent_Id > 0) { var rootCategory = _categoryService.GetById(Id: model.Parent_Id); category.Parent = rootCategory; } category.Name = model.Name; _categoryService.Create(category); if (_unitOfWork.SaveAllChanges() > 0) { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccsessInsert), Status = AlertMode.success })); } else { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailInsert), Status = AlertMode.warning })); } }
public virtual PartialViewResult SubmitDeleteProductPerPackage(int Package_Id, string array) { int[] arrayResult = Array.ConvertAll(array.Split(','), x => int.Parse(x)).ToArray(); var package = _packageService.GetById(Package_Id); var productList = package.Products.Where(x => !arrayResult.Contains(x.Id)).ToList(); package.Products = productList; _packageService.Update(package); if (_unitOfWork.SaveAllChanges() > 0) { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccsessUpdate), Status = AlertMode.success })); } else { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailUpdate), Status = AlertMode.warning })); } }
public virtual ActionResult DeletePackage(int id) { var package = _packageService.GetById(id); if (System.IO.File.Exists(Server.MapPath("~/Content/Images/Package/" + package.Image))) { System.IO.File.Delete(Server.MapPath("~/Content/Images/Package/" + package.Image)); } _packageService.Delete(package); if (_unitOfWork.SaveAllChanges() > 0) { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccsessDelete), Status = AlertMode.success })); } else { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailDelete), Status = AlertMode.warning })); } }
public virtual PartialViewResult CreateLabel(Label label) { if (_labelService.IsExistLabel(label.Name)) { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.DuplicateName), Status = AlertMode.info })); } else { _labelService.Create(label); if (_unitOfWork.SaveAllChanges() > 0) { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccsessInsert), Status = AlertMode.success })); } else { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailInsert), Status = AlertMode.warning })); } } }
public virtual async Task <ActionResult> DisableUser(DisableUserViewModel disableUser) { var userAdmin = await _userManager.FindByIdAsync(disableUser.Id); //userAdmin.LockoutEnabled = !disableUser.Status; userAdmin.DisableUser = disableUser.Status; var result = await _userManager.UpdateAsync(userAdmin); if (result.Succeeded) { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccsessUpdate), Status = AlertMode.success })); } else { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailUpdate), Status = AlertMode.warning })); } }
public virtual ActionResult SendMessage(SendSMSProfileViewModel model) { try { string userName = WebConfigurationManager.AppSettings["UserNameSMS"]; string password = WebConfigurationManager.AppSettings["PasswordSMS"]; string NumberSMS = WebConfigurationManager.AppSettings["NumberSMS"]; SendSoapClient client = new SendSoapClient(); string result = client.SendSimpleSMS2(userName, password, model.Phone, NumberSMS, model.Explain, false); return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccessSend), Status = AlertMode.success })); } catch { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailSend), Status = AlertMode.warning })); } }
public virtual ActionResult DeleteImageProduct(List <string> checkboxImage, int Id) { var list = new List <ImageProduct>(); var address = Server.MapPath("~/Content/Images/Product/GallerySize/"); foreach (var item in checkboxImage) { list.Add(new ImageProduct { Id = int.Parse(item.Split('/')[0]) }); TODO.DeleteImage(Path.Combine(address, item.Split('/')[1])); } _unitOfWork.RemoveRange <ImageProduct>(list); if (_unitOfWork.SaveAllChanges() > 0) { //Remove Id From Document LuceneProductSearch.ClearLuceneIndexRecord(Id); return(RedirectToAction(actionName: MVC.admin.Product.ActionNames.DetailsProduct, routeValues: new { Id = Id })); } else { ViewData["deleteImageProduct"] = Helperalert.alert(new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.Dependencies), Status = AlertMode.info }); return(RedirectToAction(MVC.admin.Product.ActionNames.DeleteImageProduct, new { Id = Id })); } }
public virtual PartialViewResult DeleteCity(int Id) { try { if (_cityService.IsExistCityById(Id)) { _cityService.Delete(_cityService.GetById(Id)); if (_unitOfWork.SaveAllChanges() > 0) { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccsessDelete), Status = AlertMode.success })); } else { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailDelete), Status = AlertMode.warning })); } } else { //باید خطا این باشد : چنین رکوردی موجود نیست return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailDelete), Status = AlertMode.warning })); } } catch { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.Dependencies), Status = AlertMode.info })); } }
public virtual ActionResult DeleteImageSlider(List <string> checkboxImage) { var listId = new List <Slider>(); var listName = new List <string>(); foreach (var item in checkboxImage) { listId.Add(new Slider { Id = int.Parse(item.Split('/')[0]) }); listName.Add(item.Split('/')[1]); } _unitOfWork.RemoveRange <Slider>(listId); if (_unitOfWork.SaveAllChanges() > 0) { foreach (var item in listName) { TODO.DeleteImage(Server.MapPath("~/Content/Images/Slider/" + item)); } return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccsessDelete), Status = AlertMode.success })); } else { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailDelete), Status = AlertMode.warning })); } }
public virtual async Task <ActionResult> Login(LoginViewModel model, string ReturnUrl) { if (ModelState.IsValid) { var user = await _userManager.FindByEmailAsync(model.Email); if (user != null) { if (!user.DisableUser) { var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false); switch (result) { case SignInStatus.Failure: return(Json(new { Result = Helperalert.alert(new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailLogin), Status = AlertMode.warning }).ToString(), Status = false }, JsonRequestBehavior.AllowGet)); case SignInStatus.LockedOut: return(null); // return Json(new { Result = Helperalert.alert(new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.DuplicateName), Status = AlertMode.info }).ToString(), Status = false, Redirect = "Home/Index" }, JsonRequestBehavior.AllowGet); case SignInStatus.RequiresVerification: return(null); case SignInStatus.Success: return(Json(new { Result = Helperalert.alert(new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccessLogin), Status = AlertMode.success }).ToString(), Status = true, Redirect = (string.IsNullOrEmpty(ReturnUrl)) ? HttpContext.Request.UrlReferrer.AbsolutePath : ReturnUrl }, JsonRequestBehavior.AllowGet)); //HttpContext.Request.UrlReferrer.AbsolutePath default: return(null); } } else { return(Json(new { Result = Helperalert.alert(new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.DisableUser), Status = AlertMode.warning }).ToString(), Status = false, Redirect = "Home/Index" }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { Result = Helperalert.alert(new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.NoExistUser), Status = AlertMode.info }).ToString(), Status = false }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { Result = Helperalert.alert(new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.Invalid), Status = AlertMode.info }).ToString(), Status = false }, JsonRequestBehavior.AllowGet)); } }
public async virtual Task <ActionResult> CompleteInformation(UpdateProfileUserViewModel model) { if (!ModelState.IsValid) { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.Invalid), Status = AlertMode.warning })); } var user = await _userManager.FindByIdAsync(User.Identity.GetUserId <int>()); AddressUser newAddress = new AddressUser(); newAddress.City = _cityService.GetById(model.City_Id); newAddress.Province = _provinceService.GetById(model.Province_Id);; newAddress.PostalCode = model.PostalCode; newAddress.Address = model.Address; if (user.Address != null) { user.Address.Province = newAddress.Province; user.Address.City = newAddress.City; user.Address.PostalCode = newAddress.PostalCode; user.Address.Address = newAddress.Address; } else { user.Address = newAddress; } user.PhoneNumber = model.Phone; user.Name = model.Name; user.Family = model.Family; user.ReciveMessage = model.ReciveMessage; var resultOperation = await _userManager.UpdateAsync(user); if (resultOperation.Succeeded) { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccsessUpdate), Status = AlertMode.success })); } else { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailUpdate), Status = AlertMode.warning })); } }
public virtual ActionResult CreateCompany(CompanyAddViewModel model) { //1048576 Bytes == 1024 * 1024 KB == 1 MB ---> 1024 if (ModelState.IsValid) { try { if (model.Image != null) { if (model.Image.ContentLength > 0) { using (var img = Image.FromStream(model.Image.InputStream)) { string fileName = TODO.CheckExistFile(Server.MapPath("~/Content/Images/Company/"), model.Image.FileName); TODO.UploadImage(img, new Size(70, 70), Server.MapPath("~/Content/Images/Company/"), fileName); model.ImageLogo = fileName; } } } model.Title = HelperTitle.GetTitle(Address: model.Address); var company = new Company { Address = model.Address, ImageLogo = model.ImageLogo, Explain = model.Explain, Name = model.Name, Title = model.Title }; _companyService.Create(company); if (_unitOfWork.SaveAllChanges() > 0) { return(RedirectToAction(MVC.admin.Company.ActionNames.DetailsCompany, new { Id = company.Id })); } else { TempData["createCompany"] = Helperalert.alert(new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailInsert), Status = AlertMode.warning }); return(View()); } } catch { TempData["createCompany"] = Helperalert.alert(new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailInsert), Status = AlertMode.warning }); return(View()); } } else { return(View()); } }
public virtual async Task <ActionResult> ForgotPassword(ForgetPasswordViewModel model) { if (ModelState.IsValid) { var user = await _userManager.FindByNameAsync(model.Email); var result = await _userManager.IsEmailConfirmedAsync(user.Id); if (user == null || !(await _userManager.IsEmailConfirmedAsync(user.Id))) { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.NoExistEmail), Status = AlertMode.info })); } try { var code = await _userManager.GeneratePasswordResetTokenAsync(user.Id); var callbackUrl = Url.Action(MVC.Account.ActionNames.ResetPassword, MVC.Account.Name, new { userId = user.Id, code }, protocol: Request.Url.Scheme); string Messagedate = ConvertDate.PerssionDate(DateTime.Now); string Explainbody; using (var reader = new StreamReader(Server.MapPath("~/EmailConfiguration/TemplateEmail/_ForgotPassword.txt"))) { Explainbody = reader.ReadToEnd(); } string UserName = ((user.Name != null) && (user.Family != null)) ? string.Concat(user.Name + " " + user.Family) : user.Email; string resultBody = string.Format(Explainbody, UserName, "ویرایش رمز عبور", callbackUrl, Messagedate); await _userManager.SendEmailAsync(user.Id, "ویرایش رمز عبور در فناوران اطلاعات ارم وب", resultBody); return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.ResetPassword), Status = AlertMode.success })); } catch { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailSendEmail), Status = AlertMode.warning })); } } return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.Invalid), Status = AlertMode.warning })); }
public virtual ActionResult UpdateProvince(Province province) { _provinceService.Update(province); if (_unitOfWork.SaveAllChanges() > 0) { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccsessUpdate), Status = AlertMode.success })); } else { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailUpdate), Status = AlertMode.warning })); } }
public async virtual Task <ActionResult> Index(ContactUsViewModel model) { if (ModelState.IsValid) { var user = await _userManager.FindByIdAsync(User.Identity.GetUserId <int>()); if (user.Name == null || user.Family == null || user.PhoneNumber == null) { user.PhoneNumber = model.Phone; user.Name = model.Name; user.Family = model.Family; } var resultOperation = await _userManager.UpdateAsync(user); if (resultOperation.Succeeded) { _contactService.Create(new ContactUs { ApplicationUser = user, Date = DateTime.Now, Explain = model.Explain.ToSafeHtml(), StatusRead = false, StatusAnswer = false }); if (_unitOfWork.SaveAllChanges() > 0) { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccessSend), Status = AlertMode.success })); } else { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailSend), Status = AlertMode.warning })); } } else { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailSend), Status = AlertMode.warning })); } } else { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.Invalid), Status = AlertMode.warning })); } }
public virtual PartialViewResult DeleteSale(int Id) { var orders = _orderService.GetAllOrderBySaleId(Id); _unitOfWork.RemoveRange <Order>(orders); _saleService.Delete(_saleService.GetById(Id)); if (_unitOfWork.SaveAllChanges() > 0) { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccsessDelete), Status = AlertMode.success })); } else { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailDelete), Status = AlertMode.warning })); } }
public virtual PartialViewResult FavoriteListUser(int Id) { var arrayProduct = _favoriteService.GetAllIdProductForUser(Id); if (arrayProduct.Length > 0) { var list = _productService.GetDataTableInterestUser(arrayProduct); return(PartialView(viewName: MVC.admin.Manage.Views._FavoriteListUser, model: list)); } else { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.NoItem), Status = AlertMode.White })); } }
public virtual ActionResult AddProductToFavorite(int?productId) { try { int _productId = productId ?? 0; var userId = User.Identity.GetUserId <int>(); if (_productService.IsExistById(_productId)) { if (_productId > 0 && userId > 0) { _favoriteUserService.Create(new Interest { User_Id = userId, Product_Id = _productId }); if (_unitOfWork.SaveAllChanges() > 0) { return(PartialView(MVC.Favorite.Views._StatusButtomFavoriteUser, new StatusButtonFavoriteViewModel { Status = true, Product_Id = _productId })); } else { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.AddFavoriteError), Status = AlertMode.warning })); } } else { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.AddFavoriteError), Status = AlertMode.warning })); } } else { return(Content("")); } } catch { return(Content("")); } }
public virtual PartialViewResult DeleteProduct(int Id) { var imageProduct = _imageProductService.GetAllBySerachIdProduct(Product_Id: Id); if (imageProduct != null) { _unitOfWork.RemoveRange(imageProduct); } var product = _productService.GetById(Id: Id); _productService.Delete(product); if (_unitOfWork.SaveAllChanges() > 0) { //Delete Dependence Image foreach (var item in imageProduct) { if (System.IO.File.Exists(Server.MapPath("~/Content/Images/Product/" + item.Image))) { System.IO.File.Delete(Server.MapPath("~/Content/Images/Product/" + item.Image)); } } //Delete Primary Image if (System.IO.File.Exists(Server.MapPath("~/Content/Images/Product/" + product.PrimryImage))) { System.IO.File.Delete(Server.MapPath("~/Content/Images/Product/" + product.PrimryImage)); } return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccsessDelete), Status = AlertMode.success })); } else { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailDelete), Status = AlertMode.warning })); } }
public virtual PartialViewResult DeleteLabel(int Id) { _labelService.Delete(_labelService.GetById(Id: Id)); if (_unitOfWork.SaveAllChanges() > 0) { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccsessInsert), Status = AlertMode.success })); } else { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailInsert), Status = AlertMode.warning })); } }
public virtual ActionResult CreateProvince(ProvinceAddViewModel provinceViewModel) { var province = new Province { Name = provinceViewModel.Name }; _provinceService.Create(province); if (_unitOfWork.SaveAllChanges() > 0) { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccsessInsert), Status = AlertMode.success })); } else { return(PartialView(viewName: MVC.admin.Shared.Views._alert, model: new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailInsert), Status = AlertMode.warning })); } }
public virtual ActionResult UpdateCity(City city) { City newCity = new City(); newCity.Name = city.Name; newCity.Id = city.Id; newCity.Province = _provinceService.GetById(city.Province.Id); _cityService.Update(newCity); if (_unitOfWork.SaveAllChanges() > 0) { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.SuccsessUpdate), Status = AlertMode.success })); } else { return(PartialView(MVC.admin.Shared.Views._alert, new AlertViewModel { Alert = AlertOperation.SurveyOperation(StatusOperation.FailUpdate), Status = AlertMode.warning })); } }