Пример #1
0
        public ActionResult AddClientPrivateLabel(ClientPrivateLabel _ClientPrivateLabel)
        {
            try
            {
                if (_ClientPrivateLabel.ClientPrivateLabelLogo != null)
                {
                    _ClientPrivateLabel.ClientPrivateLabelLogoName = GlobalConst.VirtualPathFolders.ClientPrivateLableLogo + Path.GetExtension(_ClientPrivateLabel.ClientPrivateLabelLogo.FileName);
                }

                string[] _ids = new string[2];
                if (_ClientPrivateLabel.ClientPrivateLabelID > 0)
                {
                    _ids[0] = "Update";

                    if (_ClientPrivateLabel.ClientPrivateLabelLogoName != null)
                    {
                        _ClientPrivateLabel.ClientPrivateLabelLogoName = Path.GetFileName(_ClientPrivateLabel.ClientPrivateLabelLogoName);
                    }

                    _iClientService.updateClientPrivateLabel(Mapper.Map <MMC.MMCService.ClientService.ClientPrivateLabel>(_ClientPrivateLabel));
                    _ids[1] = _ClientPrivateLabel.ClientPrivateLabelID.ToString();
                    if (_ClientPrivateLabel.ClientPrivateLabelLogo != null)
                    {
                        StorageService _storageService;
                        _storageService = new StorageService();
                        var path = _storageService.GeneateStorageByStoragePath(Server.MapPath(System.Configuration.ConfigurationManager.AppSettings[GlobalConst.VirtualDirectoryPath.VirtualPath].ToString()) + GlobalConst.ConstantChar.DoubleBackSlash + _ClientPrivateLabel.ClientID.ToString() + GlobalConst.ConstantChar.DoubleBackSlash + GlobalConst.VirtualPathFolders.ClientPrivateLableLogo) + GlobalConst.ConstantChar.DoubleBackSlash + _ClientPrivateLabel.ClientPrivateLabelLogoName;
                        if ((System.IO.File.Exists(path)))
                        {
                            System.IO.File.Delete(path);
                        }
                        _ClientPrivateLabel.ClientPrivateLabelLogo.SaveAs(path);
                    }
                }
                else
                {
                    _ids[0] = "Add";
                    _ClientPrivateLabel.ClientPrivateLabelID = _iClientService.addClientPrivateLabel(Mapper.Map <MMC.MMCService.ClientService.ClientPrivateLabel>(_ClientPrivateLabel));
                    if (_ClientPrivateLabel.ClientPrivateLabelLogo != null)
                    {
                        StorageService _storageService;
                        _storageService = new StorageService();
                        var path = _storageService.GeneateStorageByStoragePath(Server.MapPath(System.Configuration.ConfigurationManager.AppSettings[GlobalConst.VirtualDirectoryPath.VirtualPath].ToString()) + GlobalConst.ConstantChar.DoubleBackSlash + _ClientPrivateLabel.ClientID.ToString() + GlobalConst.ConstantChar.DoubleBackSlash + GlobalConst.VirtualPathFolders.ClientPrivateLableLogo) + GlobalConst.ConstantChar.DoubleBackSlash + _ClientPrivateLabel.ClientPrivateLabelLogoName;
                        _ClientPrivateLabel.ClientPrivateLabelLogo.SaveAs(path);
                    }

                    _ids[1] = _ClientPrivateLabel.ClientPrivateLabelID.ToString();
                }
                return(Json(_ids, GlobalConst.ContentTypes.TextHtml, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json("0"));
            }
        }