Example #1
0
        public ActionResult AddDesignCompany(DesignCompany designCompany)
        {
            var allDesignCompanyList = _userAccessDataControlService.GetAllDesignCompany();
            if (allDesignCompanyList.Exists(x => x.Name == designCompany.Name.Trim()))
            {
                TempData["errorMsg"] = "设计公司不能重复!";
                return RedirectToAction("AddDesignCompany");
            }
            _userAccessDataControlService.AddDesignCompany(designCompany);

            return RedirectToAction("DesignCompanyList");
        }
        public void intergration_test_for_user_access_data_control_for_design_company()
        {
            #region DesignCompany CRUD
            DesignCompany dc1 = new DesignCompany
            {
                Name = "dc1",
                Description = "dc1 desc",
            };

            DesignCompany dc2 = new DesignCompany
            {
                Name = "dc2",
                Description = "dc2 desc",
            };

            DesignCompany dc3 = new DesignCompany
            {
                Name = "dc3",
                Description = "dc3 desc",
            };
            string dcId1 = userAccessDataControlService.AddDesignCompany(dc1);
            string dcId2 = userAccessDataControlService.AddDesignCompany(dc2);
            string dcId3 = userAccessDataControlService.AddDesignCompany(dc3);

            #region Add Users and App Project Ids into DesignCompany
            userAccessDataControlService.AddUserToDesignCompany("ike", dcId1);
            userAccessDataControlService.AddUserToDesignCompany("ike1", dcId1);
            userAccessDataControlService.AddUserToDesignCompany("ike2", dcId1);

            userAccessDataControlService.AddUserToDesignCompany("ike", dcId2);
            userAccessDataControlService.AddUserToDesignCompany("Mike1", dcId2);
            userAccessDataControlService.AddUserToDesignCompany("Mike2", dcId2);

            userAccessDataControlService.AddUserToDesignCompany("ike", dcId3);

            userAccessDataControlService.AddAppProjectToDesignCompany("1", dcId1);
            userAccessDataControlService.AddAppProjectToDesignCompany("2", dcId1);
            userAccessDataControlService.AddAppProjectToDesignCompany("1", dcId2);
            userAccessDataControlService.AddAppProjectToDesignCompany("2", dcId2);
            userAccessDataControlService.AddAppProjectToDesignCompany("2", dcId3);

            #endregion

            dc2.Name = "dc2 updated";
            userAccessDataControlService.UpdateDesignCompany(dc2);
            userAccessDataControlService.DeleteDesignCompany(dcId3);

            Assert.Equal(2, userAccessDataControlService.GetAllDesignCompany().Count);
            Assert.Equal("dc2 updated", userAccessDataControlService.GetDesignCompany(dcId2).Name);
            #endregion

            #region User DesignCompany relations asserts
            var userList1 = userAccessDataControlService.GetUsersByDesignCompany(dcId1);
            Assert.Equal(3, userList1.Count);

            var dcList1 = userAccessDataControlService.GetDesignCompaniesByUser("ike");
            Assert.Equal(1, dcList1.Count);

            userAccessDataControlService.RemoveUserFromDesignCompany("ike", dcId1);
            userList1 = userAccessDataControlService.GetUsersByDesignCompany(dcId1);
            Assert.Equal(2, userList1.Count);

            #endregion

            #region AppProject DesignCompany relations asserts
            var appList1 = userAccessDataControlService.GetAppProjectIdsByDesignCompany(dcId1);
            Assert.Equal(2, appList1.Count);

            dcList1 = userAccessDataControlService.GetDesignCompaniesByAppProjectId("1");
            Assert.Equal(2, dcList1.Count);

            userAccessDataControlService.RemoveAppProjectFromDesignCompany("1", dcId1);
            appList1 = userAccessDataControlService.GetAppProjectIdsByDesignCompany("1");
            Assert.Equal(1, appList1.Count);
            dcList1 = userAccessDataControlService.GetDesignCompaniesByAppProjectId("1");
            Assert.Equal(1, dcList1.Count);
            #endregion
        }
Example #3
0
        public ActionResult UpdateDesignCompany(DesignCompany designCompany)
        {
            var origin = _userAccessDataControlService.GetDesignCompany(designCompany.Id);
            origin.CreateDateTime = designCompany.CreateDateTime;
            origin.Description = designCompany.Description;
            origin.ModuleName = designCompany.ModuleName;
            origin.Name = designCompany.Name;

            _userAccessDataControlService.UpdateDesignCompany(origin);

            return RedirectToAction("DesignCompanyList");
        }