Пример #1
0
        // 22.07.2014   thuyhk
        public ActionResult EditLogo(string tenantId, string linked, string twitter, string facebook, string google)
        {
            int id          = Convert.ToInt32(tenantId);
            int countUpdate = 0;
            var crm_tenant  = _tenantService.Find(id);

            if (!string.IsNullOrEmpty(_logoModel.FileName))
            {
                crm_tenant.CompanyLogo = _pathFiles + "/" + _logoModel.FileName;

                //move a file from temps file to tenant folder
                var _sourceFile      = Path.Combine(Server.MapPath(_tempFiles), _logoModel.FileName);
                var _destinationFile = Path.Combine(Server.MapPath(_pathFiles), _logoModel.FileName);
                if (System.IO.File.Exists(_destinationFile))
                {
                    System.IO.File.Delete(_destinationFile);
                }
                System.IO.File.Move(_sourceFile, _destinationFile);

                _logoModel = null;
                countUpdate++;
            }

            if (crm_tenant.LinkedURL != linked)
            {
                crm_tenant.LinkedURL = linked;
                countUpdate++;
            }

            if (crm_tenant.FacebookURL != facebook)
            {
                crm_tenant.FacebookURL = facebook;
                countUpdate++;
            }

            if (crm_tenant.TwitterURL != twitter)
            {
                crm_tenant.TwitterURL = twitter;
                countUpdate++;
            }

            if (crm_tenant.GoogleplusURL != google)
            {
                crm_tenant.GoogleplusURL = google;
                countUpdate++;
            }
            if (countUpdate > 0)
            {
                crm_tenant.ModifiedDate = DateTime.Now;
                crm_tenant.ObjectState  = ObjectState.Modified;
                _tenantService.Update(crm_tenant);
                _unitOfWork.SaveChanges();
                return(Content("Update success!"));
            }
            else
            {
                return(Content("No change"));
            }
        }
Пример #2
0
        /// <summary>
        /// View information of usergroup
        /// </summary>
        /// <param name="id">usergroup's id</param>
        /// <returns></returns>
        public ActionResult ViewDetail(int id = 0)
        {
            //variables
            crm_Roles      roleItem;
            UserGroupModel model = new UserGroupModel();
            crm_Tenants    tenant;

            try
            {
                //Check invalid id
                if (id == 0)
                {
                    return(View("Index"));
                }

                //Get role detail
                roleItem = _roleService.GetRoleByID(id);

                //Check null data
                if (roleItem == null)
                {
                    return(View("Index"));
                }

                //Set permission type name
                foreach (UserGroupEnum usergroup in Enum.GetValues(typeof(UserGroupEnum)))
                {
                    if (roleItem.PermissionType.HasValue)
                    {
                        if (roleItem.PermissionType.Value == Convert.ToInt32(usergroup))
                        {
                            model.PermissionTypeName = usergroup.ToString();
                            break;
                        }
                    }
                }

                tenant = _tenantService.Find(roleItem.TenantId);

                //set value for model
                model.ID          = roleItem.ID;
                model.Name        = roleItem.RoleName;
                model.Active      = roleItem.Active.HasValue ? roleItem.Active.Value : false;
                model.Description = roleItem.Description;
                model.TenantName  = tenant == null ? "" : tenant.TenantName;

                return(View(model));
            }
            catch
            {
                return(View("Index"));
            }
        }
Пример #3
0
        // GET: /Tenant/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var _tenant = _tenantService.Find(id);

            if (_tenant == null)
            {
                return(HttpNotFound());
            }

            var model      = _tenant.ToModel();
            int _countryId = Convert.ToInt32(model.CountryId);

            model.CountryName = _countryService.GetCountryById(_countryId).CountryName;

            return(View(model));
        }