public void CopyToClipboard(string s)
    {
        TextEditor te = new TextEditor();

        te.text = s;
        te.SelectAll();
        te.Copy();

        logText.Log("Copied to clipboard: \n" + s);
    }
예제 #2
0
        public ActionResult Edit(OrderViewModel orderView, string returnUrl)
        {
            ActionResult action;

            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", MessageUI.ErrorMessage);
                    return(View(orderView));
                }

                var map = Mapper.Map <OrderViewModel, Order>(orderView);
                _orderService.Update(map);

                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.UpdateSuccess, FormUI.Order)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    action = RedirectToAction("Index");
                }
                else
                {
                    action = Redirect(returnUrl);
                }
            }
            catch (Exception ex)
            {
                LogText.Log(string.Concat("Order.Edit: ", ex.Message));

                return(View(orderView));
            }
            return(action);
        }
예제 #3
0
        public ActionResult Delete(string[] ids)
        {
            try
            {
                if (ids.Length != 0)
                {
                    var staticContents =
                        from id in ids
                        select _staticContentService.GetById(int.Parse(id));

                    _staticContentService.BatchDelete(staticContents);

                    ////Check and delete logo exists
                    //string str1 = string.Format("{0}", item.FileName.NonAccent());
                    //if (System.IO.File.Exists(str))
                    //    System.IO.File.Delete(str);

                    //Delete localize
                    for (var i = 0; i < ids.Length; i++)
                    {
                        var ieLocalizedProperty
                            = _localizedPropertyService.GetByEntityId(int.Parse(ids[i]));
                        _localizedPropertyService.BatchDelete(ieLocalizedProperty);
                    }
                }
            }
            catch (Exception ex)
            {
                LogText.Log(Concat("StaticContent.Delete: ", ex.Message));
            }

            return(RedirectToAction("Index"));
        }
예제 #4
0
        public ActionResult Edit(BrandViewModel model, string returnUrl)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", MessageUI.ErrorMessage);
                    return(View(model));
                }

                var modelMap = Mapper.Map <BrandViewModel, Brand>(model);
                _brandService.Update(modelMap);

                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.UpdateSuccess, FormUI.Brand)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    return(RedirectToAction("Index"));
                }

                return(Redirect(returnUrl));
            }
            catch (Exception ex)
            {
                LogText.Log(string.Concat("Brand.Create: ", ex.Message));

                return(View(model));
            }
        }
예제 #5
0
        public ActionResult Delete(string[] ids)
        {
            try
            {
                if (ids.Length != 0)
                {
                    foreach (var id in ids)
                    {
                        var userId  = Guid.Parse(id);
                        var objUser = (from user in ids select UserManager.FindById(userId)).FirstOrDefault();

                        //Task<IList<UserLoginInfo>> loginInfo = _userLoginStore.GetLoginsAsync(objUser);
                        //_userLoginStore.RemoveLoginAsync(objUser, loginInfo);

                        var lstUserRole = UserManager.GetRoles(userId);
                        UserManager.RemoveFromRoles(userId, lstUserRole.ToArray());
                        UserManager.Update(objUser);
                        UserManager.Delete(objUser);
                    }
                }
            }
            catch (Exception ex)
            {
                LogText.Log(string.Concat("Post.Delete: ", ex.Message));
            }
            return(RedirectToAction("Index"));
        }
예제 #6
0
        public ActionResult Create(PageBannerViewModel pageBannerModel, string returnUrl)
        {
            ActionResult action;

            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", MessageUI.ErrorMessage);
                    return(View(pageBannerModel));
                }

                var pageBanner = Mapper.Map <PageBannerViewModel, PageBanner>(pageBannerModel);
                _pageBannerService.Create(pageBanner);
                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.PageBanner)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    action = RedirectToAction("Index");
                }
                else
                {
                    action = Redirect(returnUrl);
                }
            }
            catch (Exception exception1)
            {
                var exception = exception1;
                LogText.Log(string.Concat("PageBanner.Create: ", exception.Message));
                ModelState.AddModelError("", exception.Message);
                return(View(pageBannerModel));
            }
            return(action);
        }
        public ActionResult Create(GenericControlValueViewModel model, string returnUrl)
        {
            ActionResult action;

            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", MessageUI.ErrorMessage);
                    return(View(model));
                }

                var modelMap = Mapper.Map <GenericControlValueViewModel, GenericControlValue>(model);
                _genericControlValueService.Create(modelMap);

                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.Name)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    action = RedirectToAction("Index");
                }
                else
                {
                    action = Redirect(returnUrl);
                }
            }
            catch (Exception ex)
            {
                LogText.Log(string.Concat("GenericControlValue.Create: ", ex.Message));

                return(View(model));
            }

            return(action);
        }
예제 #8
0
 public ActionResult Delete(string[] ids)
 {
     try
     {
         if (ids.Length != 0)
         {
             var repairs         = new List <Repair>();
             var repairGalleries = new List <RepairGallery>();
             var strArrays       = ids;
             for (var i = 0; i < strArrays.Length; i++)
             {
                 var num    = int.Parse(strArrays[i]);
                 var repair = _repairService.Get(x => x.Id == num);
                 repairGalleries.AddRange(repair.RepairGalleries.ToList());
                 repairs.Add(repair);
             }
             _galleryService.BatchDelete(repairGalleries);
             _repairService.BatchDelete(repairs);
         }
     }
     catch (Exception exception1)
     {
         var exception = exception1;
         LogText.Log(string.Concat("Repair.Delete: ", exception.Message));
     }
     return(RedirectToAction("Index"));
 }
예제 #9
0
        public ActionResult Edit(PaymentMethodViewModel model, string returnUrl)
        {
            ActionResult action;

            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", MessageUI.ErrorMessage);
                    return(View(model));
                }

                var byId = _paymentMethodService.Get(x => x.Id == model.Id);

                ImageHandler(model);

                //if (model.Image != null && model.Image.ContentLength > 0)
                //{
                //    var fileExtension = Path.GetExtension(model.Image.FileName);
                //    var fileNameOriginal = Path.GetFileNameWithoutExtension(model.Image.FileName);

                //    var fileName = fileNameOriginal.FileNameFormat(fileExtension);

                //    //var fileExtension = Path.GetExtension(model.Image.FileName);
                //    //var fileName = titleNonAccent.FileNameFormat(fileExtension);

                //    _imageService.CropAndResizeImage(model.Image, $"{Contains.PaymentMethodFolder}", fileName, ImageSize.PaymentMethodWithMediumSize, ImageSize.PaymentMethodHeightMediumSize);

                //    model.ImageUrl = string.Concat(Contains.PaymentMethodFolder, fileName);
                //}

                var modelMap = Mapper.Map(model, byId);
                _paymentMethodService.Update(modelMap);

                //Update Localized
                foreach (var localized in model.Locales)
                {
                    _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.PaymentMethodSystemName, localized.PaymentMethodSystemName, localized.LanguageId);
                    _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Description, localized.Description, localized.LanguageId);
                }


                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.UpdateSuccess, FormUI.PaymentMethod)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    action = RedirectToAction("Index");
                }
                else
                {
                    action = Redirect(returnUrl);
                }
            }
            catch (Exception ex)
            {
                LogText.Log(string.Concat("PaymentMethod.Edit: ", ex.Message));
                return(View(model));
            }

            return(action);
        }
예제 #10
0
        public ActionResult Delete(int[] ids)
        {
            try
            {
                if (ids.Length != 0)
                {
                    var news =
                        from id in ids
                        select _newsService.GetById(id);

                    _newsService.BatchDelete(news);

                    //Delete localize
                    for (var i = 0; i < ids.Length; i++)
                    {
                        var ieLocalizedProperty
                            = _localizedPropertyService.GetByEntityId(ids[i]);

                        _localizedPropertyService.BatchDelete(ieLocalizedProperty);
                    }
                }
            }
            catch (Exception exception1)
            {
                var exception = exception1;
                LogText.Log(string.Concat("Post.Delete: ", exception.Message));
            }
            return(RedirectToAction("Index"));
        }
예제 #11
0
 public ActionResult Approved(string[] ids, int value)
 {
     try
     {
         if (ids.Length != 0)
         {
             var strArrays = ids;
             for (var i = 0; i < strArrays.Length; i++)
             {
                 var num         = int.Parse(strArrays[i]);
                 var landingPage = _landingPageService.Get(x => x.Id == num);
                 landingPage.Status = 3;
                 _landingPageService.Update(landingPage);
             }
             Response.Cookies.Add(new HttpCookie("system_message", MessageUI.UpdateSuccess));
         }
     }
     catch (Exception exception1)
     {
         var exception = exception1;
         Response.Cookies.Add(new HttpCookie("system_message", "Cập nhật không thành công."));
         LogText.Log(string.Concat("ContactInfor.Delete: ", exception.Message));
     }
     return(RedirectToAction("Index"));
 }
예제 #12
0
        public ActionResult Delete(int[] ids)
        {
            try
            {
                if (ids.Length != 0)
                {
                    var numArray = ids;
                    for (var i = 0; i < numArray.Length; i++)
                    {
                        var num       = numArray[i];
                        var slideShow = _slideShowService.Get(x => x.Id == num);

                        _slideShowService.Delete(slideShow);

                        //Delete localize
                        var ieLocalizedProperty = _localizedPropertyService.GetByEntityId(num);

                        _localizedPropertyService.BatchDelete(ieLocalizedProperty);
                    }
                }
            }
            catch (Exception ex)
            {
                LogText.Log(string.Concat("SlideShow.Delete: ", ex.Message));
            }

            return(RedirectToAction("Index"));
        }
예제 #13
0
        public ActionResult Delete(string[] ids)
        {
            try
            {
                if (ids.Length != 0)
                {
                    var menuLinks =
                        from id in ids
                        select _menuLinkService.GetMenu(int.Parse(id));

                    _menuLinkService.BatchDelete(menuLinks);

                    //Delete localize
                    for (var i = 0; i < ids.Length; i++)
                    {
                        var ieLocalizedProperty
                            = _localizedPropertyService.GetByEntityId(int.Parse(ids[i]));
                        _localizedPropertyService.BatchDelete(ieLocalizedProperty);
                    }
                }
            }
            catch (Exception ex)
            {
                LogText.Log(string.Concat("MenuLink.Delete: ", ex.Message));
                ModelState.AddModelError("", ex.Message);
            }
            return(RedirectToAction("Index"));
        }
예제 #14
0
        public ActionResult Edit(ProvinceViewModel provinceView, string returnUrl)
        {
            ActionResult action;

            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", MessageUI.ErrorMessage);
                    return(View(provinceView));
                }

                var province = Mapper.Map <ProvinceViewModel, Province>(provinceView);
                _provinceService.Update(province);
                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.UpdateSuccess, FormUI.Provinces)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    action = RedirectToAction("Index");
                }
                else
                {
                    action = Redirect(returnUrl);
                }
            }
            catch (Exception exception1)
            {
                var exception = exception1;
                LogText.Log(string.Concat("MailSetting.Create: ", exception.Message));
                return(View(provinceView));
            }
            return(action);
        }
예제 #15
0
        public JsonResult Update(string param)
        {
            try
            {
                //var data = JsonConvert.DeserializeObject<GenericControlValueResponseCollection>(param);

                //foreach (GenericControlValueItem item in data.GenericControlValueItem)
                //{
                //    //Get data
                //    GenericControlValueItem model = _genericControlValueItemService.Get((GenericControlValueItem x) => x.Id == item.Id && x.EntityId == item.EntityId);

                //    if (model != null)
                //    {
                //       // model = new GenericControlValueItem();
                //        model.ColorHex = item.ColorHex;
                //        model.EntityId = entityId;

                //        _genericControlValueItemService.Create(model);
                //    }
                //}
            }
            catch (Exception exception)
            {
                LogText.Log(string.Concat("District.Edit: ", exception.Message));
            }
            var jsonResult = Json(new { success = true }, JsonRequestBehavior.AllowGet);

            return(jsonResult);
        }
예제 #16
0
        public ActionResult Create(AttributeValueViewModel attributeValue, string returnUrl)
        {
            ActionResult action;

            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", MessageUI.ErrorMessage);
                    return(View(attributeValue));
                }

                var attributeValue1 = Mapper.Map <AttributeValueViewModel, AttributeValue>(attributeValue);
                _attributeValueService.Create(attributeValue1);
                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.AttributeValue)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    action = RedirectToAction("Index");
                }
                else
                {
                    action = Redirect(returnUrl);
                }
            }
            catch (Exception exception1)
            {
                var exception = exception1;
                LogText.Log(string.Concat("District.Create: ", exception.Message));
                return(View(attributeValue));
            }
            return(action);
        }
예제 #17
0
        public ActionResult Delete(string[] ids)
        {
            try
            {
                if (ids.IsAny())
                {
                    var idTest = from id in ids select id;
                    var aa     = idTest.FirstOrDefault();

                    var genericControls =
                        from id in ids
                        select _gCService.GetById(int.Parse(id));

                    _gCService.BatchDelete(genericControls);

                    //Delete localize
                    for (var i = 0; i < ids.Length; i++)
                    {
                        var localizedProperties
                            = _localizedPropertyService.GetByEntityId(int.Parse(ids[i]));

                        _localizedPropertyService.BatchDelete(localizedProperties);
                    }
                }
            }
            catch (Exception ex)
            {
                LogText.Log(string.Concat("GenericControl --> Delete: ", ex.Message));
                ModelState.AddModelError("", ex.Message);
            }

            return(RedirectToAction("Index"));
        }
예제 #18
0
        public ActionResult Edit(BannerViewModel model, string returnUrl)
        {
            ActionResult action;

            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", MessageUI.ErrorMessage);
                    return(View(model));
                }

                var byId = _bannerService.GetById(model.Id);

                ImageHandler(model);
                //if (model.Image != null && model.Image.ContentLength > 0)
                //{
                //    var folderName = CommonHelper.FolderName(model.Title);
                //    var fileNameOriginal = Path.GetFileNameWithoutExtension(model.Image.FileName);
                //    var fileExtension = Path.GetExtension(model.Image.FileName);

                //    var fileName = fileNameOriginal.FileNameFormat(fileExtension);

                //    _imageService.CropAndResizeImage(model.Image, $"{Contains.AdsFolder}{folderName}/", fileName, ImageSize.BannerWithBigSize, ImageSize.BannerHeightBigSize);

                //    model.ImgPath = $"{Contains.AdsFolder}{folderName}/{fileName}";
                //    //var fileName = Path.GetFileName(model.Image.FileName);
                //    //var extension = Path.GetExtension(model.Image.FileName);
                //    ////fileName = string.Concat(model.FullName.NonAccent(""), extension);
                //    //var str = Path.Combine(Server.MapPath(string.Concat("~/", Contains.AdsFolder)), fileName);
                //    //model.Image.SaveAs(str);
                //    //model.ImgPath = string.Concat(Contains.AdsFolder, fileName);
                //}

                var banner = Mapper.Map(model, byId);
                _bannerService.Update(banner);

                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.UpdateSuccess, FormUI.Banner)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    action = RedirectToAction("Index");
                }
                else
                {
                    action = Redirect(returnUrl);
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                LogText.Log(string.Concat("Banner.Edit: ", ex.Message));

                return(View(model));
            }
            return(action);
        }
예제 #19
0
        public ActionResult Edit(ManufacturerViewModel model, string returnUrl)
        {
            ActionResult action;

            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", MessageUI.ErrorMessage);

                    return(View(model));
                }

                var byId = _manufacturerService.Get(x => x.Id == model.Id);

                ImageHandler(model);

                //if (model.Image != null && model.Image.ContentLength > 0)
                //{
                //    var folderName = CommonHelper.FolderName(model.Title);
                //    var fileExtension = Path.GetExtension(model.Image.FileName);
                //    var fileNameOriginal = Path.GetFileNameWithoutExtension(model.Image.FileName);

                //    var fileName = fileNameOriginal.FileNameFormat(fileExtension);

                //    _imageService.CropAndResizeImage(model.Image, $"{Contains.ManufactureFolder}{folderName}/", fileName, ImageSize.ManufactureWithMediumSize, ImageSize.ManufactureHeightMediumSize);

                //    model.ImageUrl = $"{Contains.ManufactureFolder}{folderName}/{fileName}";
                //}

                var manufacturer = Mapper.Map(model, byId);

                _manufacturerService.Update(manufacturer);

                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.UpdateSuccess, FormUI.Manufacturer)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    action = RedirectToAction("Index");
                }
                else
                {
                    action = Redirect(returnUrl);
                }
            }
            catch (Exception ex)
            {
                LogText.Log(string.Concat("Manufacturer.Edit: ", ex.Message));

                return(View(model));
            }

            return(action);
        }
예제 #20
0
        public async Task <ActionResult> Edit(RegisterFormViewModel model, string returnUrl)
        {
            ActionResult action;

            try
            {
                model.Created = null;
                var identityUser = UserManager.FindById(model.Id);
                identityUser = Mapper.Map(model, identityUser);
                var identityResult = await UserManager.UpdateAsync(identityUser);

                if (identityResult.Succeeded)
                {
                    if (model.IsSuperAdmin)
                    {
                        var roles = UserManager.GetRoles(model.Id);
                        UserManager.RemoveFromRoles(model.Id, roles.ToArray());
                    }
                    else
                    {
                        var item = Request["roles"];
                        if (!string.IsNullOrEmpty(item))
                        {
                            var lstUserRole = UserManager.GetRoles(model.Id);
                            UserManager.RemoveFromRoles(model.Id, lstUserRole.ToArray());
                            var strArrays = item.Split(',');
                            UserManager.AddToRoles(model.Id, strArrays);
                        }
                    }
                    Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.UpdateSuccess, FormUI.Account)));
                    if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                    {
                        action = RedirectToAction("Index");
                        return(action);
                    }

                    action = Redirect(returnUrl);
                    return(action);
                }

                AddErrors(identityResult);
                action = View(model);
                return(action);
            }
            catch (Exception exception1)
            {
                var exception = exception1;
                LogText.Log(string.Concat("Account.Update: ", exception.Message));
            }
            action = View();
            return(action);
        }
예제 #21
0
        public ActionResult Edit(LanguageFormViewModel model, string returnUrl)
        {
            ActionResult action;

            try
            {
                if (!ModelState.IsValid)
                {
                    var messages = String.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors)
                                               .Select(v => v.ErrorMessage + " " + v.Exception));
                    ModelState.AddModelError("", messages);
                    return(View(model));
                }

                if (model.File != null && model.File.ContentLength > 0)
                {
                    var fileNameOriginal = Path.GetFileNameWithoutExtension(model.File.FileName);
                    var fileExtension    = Path.GetExtension(model.File.FileName);
                    var fileName         = fileNameOriginal.FileNameFormat(fileExtension);

                    //var fileName = Path.GetFileNameWithoutExtension(model.File.FileName);

                    var path = Path.Combine(Server.MapPath(string.Concat("~/", Constant.FolderLanguage)), fileName);

                    model.File.SaveAs(path);
                    model.Flag = string.Concat(Constant.FolderLanguage, fileName);
                }

                var modelMap = Mapper.Map <LanguageFormViewModel, Language>(model);
                _langService.Update(modelMap);

                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.UpdateSuccess, FormUI.Language)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    action = RedirectToAction("Index");
                }
                else
                {
                    action = Redirect(returnUrl);
                }
            }
            catch (Exception ex)
            {
                LogText.Log(string.Concat("Language.Edit: ", ex.Message));

                return(View(model));
            }

            return(action);
        }
예제 #22
0
        public ActionResult DeleteOne(int id)
        {
            try
            {
                var menuLink = _menuLinkService.GetMenu(id);

                _menuLinkService.Delete(menuLink);
            }
            catch (Exception ex)
            {
                LogText.Log(string.Concat("MenuLink.DeleteById: ", ex.Message));

                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.ErrorMessageWithFormat, ex.Message)));
            }
            return(RedirectToAction("Index"));
        }
예제 #23
0
        public ActionResult Create(SlideShowViewModel model, string returnUrl)
        {
            ActionResult action;

            try
            {
                if (!ModelState.IsValid)
                {
                    var messages = String.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors)
                                               .Select(v => v.ErrorMessage + " " + v.Exception));
                    ModelState.AddModelError("", messages);

                    return(View(model));
                }

                ImageHandler(model);

                var modelMap = Mapper.Map <SlideShowViewModel, SlideShow>(model);
                _slideShowService.Create(modelMap);

                //Update Localized
                foreach (var localized in model.Locales)
                {
                    _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Title, localized.Title, localized.LanguageId);
                    _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Description, localized.Description, localized.LanguageId);
                }

                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.SlideShow)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    action = RedirectToAction("Index");
                }
                else
                {
                    action = Redirect(returnUrl);
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                LogText.Log(string.Concat("SlideShow.Edit: ", ex.Message));

                return(View(model));
            }

            return(action);
        }
예제 #24
0
        public ActionResult Delete(string[] ids)
        {
            try
            {
                if (ids.IsAny())
                {
                    var posts         = new List <Post>();
                    var galleryImages = new List <GalleryImage>();
                    var orderItems    = new List <OrderItem>();
                    IEnumerable <LocalizedProperty> localizedProperties = null;

                    for (var i = 0; i < ids.Length; i++)
                    {
                        var id   = int.Parse(ids[i]);
                        var post = _postService.Get(x => x.Id == id);

                        if (post.GalleryImages.IsAny())
                        {
                            galleryImages.AddRange(post.GalleryImages.ToList());
                        }

                        post.AttributeValues.ToList().ForEach(att => post.AttributeValues.Remove(att));
                        posts.Add(post);

                        var orderItem = _orderItemService.GetByPostId(id);
                        if (orderItem != null)
                        {
                            orderItems.Add(orderItem);
                        }

                        localizedProperties = _localizedPropertyService.GetByEntityId(id);
                    }

                    _galleryService.BatchDelete(galleryImages);
                    _orderItemService.BatchDelete(orderItems);
                    _localizedPropertyService.BatchDelete(localizedProperties);
                    _postService.BatchDelete(posts);
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                LogText.Log(string.Concat("Post.Delete: ", ex.Message));
            }

            return(RedirectToAction("Index"));
        }
예제 #25
0
        public JsonResult Insert(string param, int entityId)
        {
            try
            {
                var data = JsonConvert.DeserializeObject <GenericControlValueResponse>(param);

                foreach (var item in data.controlValueItemResponse)
                {
                    //Get data
                    var model = _genericControlValueItemService.Get(x => x.EntityId == entityId &&
                                                                    x.GenericControlValueId == item.GenericControlValueId);

                    if (model != null)
                    {
                        model.Title    = item.Name;
                        model.Value    = item.ValueName;
                        model.EntityId = entityId;
                        model.GenericControlValueId = item.GenericControlValueId;

                        _genericControlValueItemService.Update(model);
                    }
                    else
                    {
                        model = new GenericControlValueItem
                        {
                            Title    = item.Name,
                            Value    = item.ValueName,
                            EntityId = entityId,
                            GenericControlValueId = item.GenericControlValueId,
                            Status       = 1,
                            OrderDisplay = 1
                        };


                        _genericControlValueItemService.Create(model);
                    }
                }
            }
            catch (Exception ex)
            {
                LogText.Log(string.Concat("District.Edit: ", ex.Message));
            }

            var jsonResult = Json(new { success = true }, JsonRequestBehavior.AllowGet);

            return(jsonResult);
        }
예제 #26
0
        public ActionResult Create(SettingSeoGlobalViewModel seoSetting, string returnUrl)
        {
            ActionResult action;

            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", MessageUI.ErrorMessage);
                    return(View(seoSetting));
                }

                if (seoSetting.Status == 1)
                {
                    var settingSeoGlobals = _settingSeoGlobal.FindBy(x => x.Status == 1);
                    if (settingSeoGlobals.IsAny())
                    {
                        foreach (var settingSeoGlobal in settingSeoGlobals)
                        {
                            settingSeoGlobal.Status = 0;
                            _settingSeoGlobal.Update(settingSeoGlobal);
                        }
                    }
                }
                var settingSeoGlobal1 = Mapper.Map <SettingSeoGlobalViewModel, SettingSeoGlobal>(seoSetting);
                _settingSeoGlobal.Create(settingSeoGlobal1);

                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.SettingSeoGlobal)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    action = RedirectToAction("Index");
                }
                else
                {
                    action = Redirect(returnUrl);
                }
            }
            catch (Exception exception1)
            {
                var exception = exception1;
                LogText.Log(string.Concat("SeoGlobal.Create: ", exception.Message));
                ModelState.AddModelError("", exception.Message);
                return(View(seoSetting));
            }
            return(action);
        }
예제 #27
0
        public ActionResult Create(PaymentMethodViewModel model, string returnUrl)
        {
            ActionResult action;

            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", MessageUI.ErrorMessage);
                    return(View(model));
                }

                ImageHandler(model);

                var modelMap = Mapper.Map <PaymentMethodViewModel, PaymentMethod>(model);
                _paymentMethodService.Create(modelMap);

                //Update Localized
                foreach (var localized in model.Locales)
                {
                    _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.PaymentMethodSystemName, localized.PaymentMethodSystemName, localized.LanguageId);
                    _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Description, localized.Description, localized.LanguageId);
                }

                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.PaymentMethod)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    action = RedirectToAction("Index");
                }
                else
                {
                    action = Redirect(returnUrl);
                }
            }
            catch (Exception ex)
            {
                LogText.Log(string.Concat("PaymentMethod.Create: ", ex.Message));
                ModelState.AddModelError("", ex.Message);

                return(View(model));
            }

            return(action);
        }
예제 #28
0
        public ActionResult Delete(string[] ids)
        {
            try
            {
                if (ids.Length != 0)
                {
                    var order =
                        from id in ids
                        select _orderService.GetById(int.Parse(id));

                    _orderService.BatchDelete(order);
                }
            }
            catch (Exception ex)
            {
                LogText.Log(string.Concat("Order.Delete: ", ex.Message));
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(ContactInforViewModel model, string returnUrl)
        {
            ActionResult action;

            try
            {
                if (!ModelState.IsValid)
                {
                    var messages = String.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors)
                                               .Select(v => v.ErrorMessage + " " + v.Exception));
                    ModelState.AddModelError("", messages);
                    return(View(model));
                }

                var modelMap = Mapper.Map <ContactInforViewModel, ContactInformation>(model);
                _contactInfoService.Update(modelMap);

                //Update Localized
                foreach (var localized in model.Locales)
                {
                    _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Title, localized.Title, localized.LanguageId);
                    _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Address, localized.Address, localized.LanguageId);
                }

                Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.UpdateSuccess, FormUI.ContactInformation)));
                if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\"))
                {
                    action = RedirectToAction("Index");
                }
                else
                {
                    action = Redirect(returnUrl);
                }
            }
            catch (Exception exception1)
            {
                var exception = exception1;
                LogText.Log(string.Concat("MailSetting.Create: ", exception.Message));
                return(View(model));
            }
            return(action);
        }
예제 #30
0
        public ActionResult Delete(string[] ids)
        {
            try
            {
                if (ids.Length != 0)
                {
                    var attributeValues =
                        from id in ids
                        select _attributeValueService.GetById(int.Parse(id));

                    _attributeValueService.BatchDelete(attributeValues);
                }
            }
            catch (Exception exception1)
            {
                var exception = exception1;
                LogText.Log(string.Concat("District.Delete: ", exception.Message));
            }
            return(RedirectToAction("Index"));
        }