Ejemplo n.º 1
0
        public ActionResult Add(HouseAddNewDTO house)
        {
            long userId = (long)AdminHelper.GetUserId(HttpContext);
            var  user   = AdminUserService.GetById(userId);

            if (user.CityId == null)
            {
                //TODO如果“总部不能***”的操作很多,也可以定义成一个AuthorizeFilter
                //最好用FilterAttribute的方式标注,这样对其他的不涉及这个问题的地方效率高
                //立即实现
                return(View("ERROR", (object)"总部不能进行房源管理"));
            }
            var houseId = HouseService.AddNew(house);

            if (houseId > 0)
            {
                //生成房源查看的html文件
                CreateStaticPages(houseId);
                return(Json(new AjaxResult()
                {
                    Status = "ok"
                }));
            }

            return(Json(new AjaxResult()
            {
                Status = "error", ErrorMsg = "添加失败"
            }));
        }
Ejemplo n.º 2
0
        public ActionResult AddHouse()
        {
            long?id     = AdminHelper.AdminUserId(HttpContext);
            long?cityId = AdminUserService.GetById(id.Value).CityId;

            if (cityId == null)
            {
                return(View("ERROR", "总部不能进行房源管理"));
            }
            var regions = RegionService.GetCityAll(cityId.Value).ToList();

            regions.Insert(0, new RegionDTO()
            {
                Id = 0, Name = "请选择"
            });
            var roomTypes           = IdNameService.GetAll("户型");
            var statuses            = IdNameService.GetAll("房屋状态");
            var decorateStatuses    = IdNameService.GetAll("装修状态");
            var attachments         = AttachmentService.GetAll();
            var types               = IdNameService.GetAll("房屋类别");
            HouseAddViewModel model = new HouseAddViewModel();

            model.Regions          = regions;
            model.RoomTypes        = roomTypes;
            model.Statuses         = statuses;
            model.DecorateStatuses = decorateStatuses;
            model.Attachments      = attachments;
            model.Types            = types;
            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult Edit(long Id)
        {
            long userId = (long)AdminHelper.GetUserId(HttpContext);
            var  user   = AdminUserService.GetById(userId);

            if (user.CityId == null)
            {
                //TODO如果“总部不能***”的操作很多,也可以定义成一个AuthorizeFilter
                //最好用FilterAttribute的方式标注,这样对其他的不涉及这个问题的地方效率高
                //立即实现
                return(View("ERROR", (object)"总部不能进行房源管理"));
            }
            var regions             = RegionService.GetAll((long)user.CityId);
            var roomTypes           = IdNameService.GetAll("户型");
            var status              = IdNameService.GetAll("房屋状态");
            var decorateStatus      = IdNameService.GetAll("装修状态");
            var types               = IdNameService.GetAll("出租类别");
            var attachments         = AttachmentService.GetAll();
            var house               = HouseService.GetById(Id);
            HouseEditGetModel model = new HouseEditGetModel();

            model.Attachments    = attachments;
            model.DecorateStatus = decorateStatus;
            model.Regions        = regions;
            model.RoomTypes      = roomTypes;
            model.Status         = status;
            model.Types          = types;
            model.House          = house;
            return(View(model));
        }
Ejemplo n.º 4
0
        public ActionResult Add()
        {
            long adminUserId = (long)Session["LoginUserId"];
            long?cityId      = AdminUserService.GetById(adminUserId).CityId;

            if (cityId == null)
            {
                return(View("Error", (object)"总部人员不能管理房源"));
            }
            var regions            = RegionService.GetAll(cityId.Value);
            var roomTypes          = IdNameService.GetAll("户型");
            var statuses           = IdNameService.GetAll("房屋状态");
            var decorationStatuses = IdNameService.GetAll("装修状态");
            var types               = IdNameService.GetAll("房屋类别");
            var attachments         = AttachmentService.GetAll();
            HouseAddViewModel model = new HouseAddViewModel()
            {
                Regions         = regions,
                RoomTypes       = roomTypes,
                Statuses        = statuses,
                DecorateStatues = decorationStatuses,
                Types           = types,
                Attachments     = attachments
            };

            return(View(model));
        }
Ejemplo n.º 5
0
        public ActionResult Add(HouseAddPostModel model)
        {
            long adminUserId = (long)Session["LoginUserId"];
            long?cityId      = AdminUserService.GetById(adminUserId).CityId;

            if (cityId == null)
            {
                return(View("Error", (object)"总部人员不能管理房源"));
            }
            var houseDTO = new HouseAddNewDTO();

            houseDTO.Address          = model.HouseAddress;
            houseDTO.AttachmentIds    = model.AttachmentIds;
            houseDTO.CheckInDateTime  = model.CheckInDate;
            houseDTO.CommunityId      = model.CommunityId;
            houseDTO.DecorateStatusId = model.DecorateStatusId;
            houseDTO.Description      = model.Description;
            houseDTO.Direction        = model.Direction;
            houseDTO.FloorIndex       = model.FloorIndex;
            houseDTO.TotalFloorCount  = model.TotalIndex;
            houseDTO.LookableDateTime = model.LookableDatetime;
            houseDTO.MonthRent        = model.MonthRent;
            houseDTO.OwnerName        = model.OwnerName;
            houseDTO.OwnerPhoneNum    = model.OwnerPhoneNum;
            houseDTO.RoomTypeId       = model.RoomTypeId;
            houseDTO.StatusId         = model.StatusId;
            houseDTO.TotalFloorCount  = model.TotalIndex;
            houseDTO.TypeId           = model.TypeId;
            houseDTO.Area             = model.HouseArea;
            HouseService.AddNew(houseDTO);
            return(Json(new AjaxResult()
            {
                Status = "ok"
            }));
        }
Ejemplo n.º 6
0
        public ActionResult Edit(long id)
        {
            long adminUserId = (long)Session["LoginUserId"];
            long?cityId      = AdminUserService.GetById(adminUserId).CityId;

            if (cityId == null)
            {
                return(View("Error", (object)"总部人员不能管理房源"));
            }
            var house              = HouseService.GetById(id);
            var regions            = RegionService.GetAll(cityId.Value);
            var roomTypes          = IdNameService.GetAll("户型");
            var statuses           = IdNameService.GetAll("房屋状态");
            var decorationStatuses = IdNameService.GetAll("装修状态");
            var types              = IdNameService.GetAll("房屋类别");
            var attachments        = AttachmentService.GetAll();
            var model              = new HouseEditViewModel();

            model.Attachments     = attachments;
            model.DecorateStatues = decorationStatuses;
            model.House           = house;
            model.Regions         = regions;
            model.RoomTypes       = roomTypes;
            model.Statuses        = statuses;
            model.Types           = types;
            return(View(model));
        }
Ejemplo n.º 7
0
        public ActionResult Console()
        {
            int            userCount      = AdminUserService.GetAll().Count();
            int            roleCount      = RoleService.GetAll().Count();
            long           id             = (long)AdminHelper.AdminUserId(HttpContext).Value;
            var            user           = AdminUserService.GetById(id);
            long           fullHouseCount = 0;
            long           joinHouseCount = 0;
            GetMainConsole console        = new GetMainConsole();

            if (user.CityId == null)
            {
                console.FullHouseCount = fullHouseCount;
                console.JoinHouseCount = joinHouseCount;
                console.RoleCount      = roleCount;
                console.UserCount      = userCount;
                return(View(console));
            }
            fullHouseCount         = HouseService.GetTotalCout(user.CityId.Value, 8);
            joinHouseCount         = HouseService.GetTotalCout(user.CityId.Value, 9);
            console.FullHouseCount = fullHouseCount;
            console.JoinHouseCount = joinHouseCount;
            console.RoleCount      = roleCount;
            console.UserCount      = userCount;
            return(View(console));
        }
Ejemplo n.º 8
0
        public ActionResult Delete(int id)
        {
            var dto = AdminUserService.GetById(id);

            AdminUserService.MarkDeleted(id);

            AdminLogService.AddNew($"删除管理员【LoginName:{dto.LoginName},UserName:{dto.UserName},Id:{dto.Id}】");
            return(Json(new AjaxResult {
                Result = true, Msg = "删除成功"
            }));
        }
Ejemplo n.º 9
0
        // GET: Default
        public ActionResult Index()
        {
            long?userId = (long?)HttpContext.Session["LoginUserId"];

            if (userId == null)
            {
                return(Redirect("~/Main/Login"));
            }
            var user = AdminUserService.GetById((long)userId);

            return(View(user));
        }
Ejemplo n.º 10
0
        // GET: House
        public ActionResult List(long typeId)
        {
            HouseListModel house = new HouseListModel();
            long           id    = (long)AdminHelper.AdminUserId(HttpContext);

            house.CityId = AdminUserService.GetById(id).CityId;
            house.TypeId = typeId;
            if (house.CityId == null)
            {
                return(View("ERROR", "总部不能进行房源管理"));
            }
            return(View(house));
        }
Ejemplo n.º 11
0
        public ActionResult List(long typeId)
        {
            long adminUserId = (long)Session["LoginUserId"];
            long?cityId      = AdminUserService.GetById(adminUserId).CityId;

            if (cityId == null)
            {
                return(View("Error", (object)"总部人员不能管理房源"));
            }
            var models = HouseService.GetPagedData(cityId.Value, typeId, 10, 0);

            return(View(models));
        }
Ejemplo n.º 12
0
        public ActionResult Edit(long id)
        {
            var user      = AdminUserService.GetById(id);
            var cities    = CityService.GetAll();
            var userRoles = RoleService.GetByAdminUserId(id);
            var allRoles  = RoleService.GetAll();
            AdminUserEditGetModel model = new AdminUserEditGetModel();

            model.User      = user;
            model.AllRoles  = allRoles;
            model.Cities    = cities;
            model.UserRoles = userRoles;
            return(View(model));
        }
Ejemplo n.º 13
0
        public void TestAddAdminUser()
        {
            long uid =
                userService.AddAdminUser("abc", "189181", "123", "*****@*****.**", null);
            var user = userService.GetById(uid);

            Assert.AreEqual(user.Name, "abc");
            Assert.AreEqual(user.PhoneNum, "189181");
            Assert.AreEqual(user.Email, "*****@*****.**");
            Assert.IsNull(user.CityId);
            Assert.IsTrue(userService.CheckLogin("189181", "123"));
            Assert.IsFalse(userService.CheckLogin("189181", "abc"));
            userService.GetAll();
            Assert.IsNotNull(userService.GetByPhoneNum("189181"));
            userService.MarkDeleted(uid);//为了保证TestCase可以重复执行,那么把创建的数据干掉
        }
Ejemplo n.º 14
0
 public void TestAdminUser()
 {
     long id = userService.AddAdminUser("abc", "13132131131", "123456", "*****@*****.**", null);
     var user= userService.GetById(id);
     Assert.AreEqual(user.Name, "abc");
     Assert.AreEqual(user.PhoneNum, "13132131131");
     Assert.AreEqual(user.Email, "*****@*****.**");
     Assert.IsNull(user.CityId);
     Assert.IsTrue(userService.CheckLogin("13132131131", "123456"));
     Assert.IsFalse(userService.CheckLogin("13132131131", "324"));
     userService.GetAll();
     Assert.IsNull(userService.GetByPhoneNum("2325252"));
     userService.GetAll(1);
     userService.UpdateAdminUser(id, "bbc", "*****@*****.**", null);
     userService.MarkDeleted(id);
 }
Ejemplo n.º 15
0
        public void TestAddAdminUser()
        {
            string phoneNum = Guid.NewGuid().ToString().Substring(0, 11);
            long   uId      = adminUserService.AddAdminUser("张三", phoneNum, "123456", "*****@*****.**", null);
            var    user     = adminUserService.GetById(uId);

            Assert.AreEqual(user.Name, "张三");
            Assert.AreEqual(user.PhoneNum, phoneNum);
            Assert.AreEqual(user.Email, "*****@*****.**");
            Assert.IsNull(user.CityId);
            Assert.IsTrue(adminUserService.CheckLogin(phoneNum, "123456"));
            Assert.IsFalse(adminUserService.CheckLogin(phoneNum, "123"));
            adminUserService.GetAll();
            Assert.IsNotNull(adminUserService.GetByPhoneNum(phoneNum));
            adminUserService.MarkDeleted(uId);
        }
Ejemplo n.º 16
0
        public void AddAdminUserTest()
        {
            AdminUserService adminService = new AdminUserService();

            long id   = new AdminUserService().AddAdminUser("cyq", "189", "mima", "123", null);
            var  user = adminService.GetById(id);

            Assert.AreEqual("cyq", user.Name);
            Assert.AreEqual("189", user.PhoneNum);
            Assert.AreEqual("123", user.Email);
            Assert.IsTrue(adminService.CheckLogin("189", "mima"));
            Assert.IsFalse(adminService.CheckLogin("189", "mima1"));
            adminService.GetAll();
            Assert.IsNotNull(adminService.GetByPhoneNum("189"));
            adminService.MarkDeleted(id);
        }
Ejemplo n.º 17
0
        public ActionResult Edit(long id)
        {
            var adminUser = AdminUserService.GetById(id);
            AdminUserEditGetViewModel adminUserEdit = new AdminUserEditGetViewModel();

            adminUserEdit.AdminUserDto = adminUser;
            adminUserEdit.RoleDtos     = RoleService.GetAll();
            var cities = CityService.GetAll().ToList();

            cities.Insert(0, new CityDTO()
            {
                Id = 0, Name = "总部"
            });
            adminUserEdit.CityDtos = cities.ToArray();
            return(View(adminUserEdit));
        }
Ejemplo n.º 18
0
        public ActionResult AddHouse(HouseAddModel model)
        {
            long?id     = AdminHelper.AdminUserId(HttpContext);
            long?cityId = AdminUserService.GetById(id.Value).CityId;

            if (cityId == null)
            {
                return(View("ERROR", "总部不能进行房源管理"));
            }
            try
            {
                HouseAddNewDTO dto = new HouseAddNewDTO();
                dto.Address          = model.address;
                dto.Area             = model.area;
                dto.AttachmentIds    = model.attachmentIds;
                dto.CheckInDateTime  = model.checkInDateTime;
                dto.CommunityId      = model.CommunityId;
                dto.DecorateStatusId = model.DecorateStatusId;
                dto.Description      = model.description;
                dto.Direction        = model.direction;
                dto.FloorIndex       = model.floorIndex;
                dto.LookableDateTime = model.lookableDateTime;
                dto.MonthRent        = model.monthRent;
                dto.OwnerName        = model.ownerName;
                dto.OwnerPhoneNum    = model.ownerPhoneNum;
                dto.RoomTypeId       = model.RoomTypeId;
                dto.StatusId         = model.StatusId;
                dto.TotalFloorCount  = model.totalFloor;
                dto.TypeId           = model.TypeId;

                long houseId = HouseService.AddNew(dto);
                return(Json(new AjaxResult <object>
                {
                    code = 0,
                    msg = "添加成功"
                }));
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("添加房源失败:{0}", ex.Message);
                return(Json(new AjaxResult <string>
                {
                    code = 1,
                    msg = ex.Message
                }));
            }
        }
Ejemplo n.º 19
0
        public void TestAddAdminUser()
        {
            long userId   = service.AddAdminUser("hhz", "13680398478", "123", "*****@*****.**", null);
            var  userInfo = service.GetById(userId);

            Assert.AreEqual(userInfo.Name, "hhz");
            Assert.AreEqual(userInfo.PhoneNum, "13680398478");
            Assert.AreEqual(userInfo.Email, "*****@*****.**");
            Assert.IsNull(userInfo.CityId);
            Assert.IsTrue(service.CheckLogin("13680398478", "123"));
            Assert.IsFalse(service.CheckLogin("13680398478", "1242"));

            service.GetAll();
            Assert.IsNotNull(service.GetByPhoneNum("13680398478"));

            service.MarkDeleted(userId);
        }
Ejemplo n.º 20
0
        public ActionResult Edit(long id)
        {
            var citys = CityService.GetAll().ToList();

            citys.Insert(0, new CityDTO()
            {
                Id = 0, Name = "总部"
            });
            AdminUserEditViewModel model = new AdminUserEditViewModel()
            {
                User        = AdminUserService.GetById(id),
                GetRolesAll = RoleService.GetAll(),
                AdminRoles  = RoleService.GetAdminRoles(id),
                GetCityAll  = citys
            };

            return(View(model));
        }
Ejemplo n.º 21
0
        public ActionResult Edit(long id)
        {
            var user     = AdminUserService.GetById(id);
            var roleIds  = RoleService.GetByAdminUserId(user.Id);
            var allRoles = RoleService.GetAll();
            var citys    = CityService.GetAll().ToList();

            citys.Add(new CityDTO {
                Id = 0, Name = "总部"
            });

            AdminUserEditModel model = new AdminUserEditModel();

            model.AdminUser     = user;
            model.SelectRoleIds = roleIds.Select(u => u.Id).ToArray();
            model.AllRoles      = allRoles;
            model.Citys         = citys.ToArray();
            return(View(model));
        }
Ejemplo n.º 22
0
        public void TestAddAdminUser()
        {
            AdminUserService auService = new AdminUserService();
            long             id        = auService.AddAdminUser("wuhuajie", "12312312312", "123456", "*****@*****.**", null);

            try
            {
                AdminUserDTO userDto = auService.GetById(id);
                Assert.AreEqual(id, userDto.Id);
                Assert.AreEqual("wuhuajie", userDto.Name);
                Assert.AreEqual("12312312312", userDto.PhoneNum);
                Assert.AreEqual(CommonHelper.CalcMD5(userDto.PasswordSalt + "123456"), userDto.PasswordHash);
                Assert.AreEqual("*****@*****.**", userDto.EMail);

                AdminUserDTO[] userDtos = auService.GetAll();
                //AminUserDTO[] userDtos2 = auService.GetAll();
                Assert.IsNotNull(userDtos);
                AdminUserDTO userDto2 = auService.GetByPhoneNum("12312312312");
                Assert.IsNotNull(userDto2);
                AdminUserDTO userDto3 = auService.GetByPhoneNum("1231231221312");
                Assert.IsNull(userDto3);
                bool login = auService.CheckLogin("12312312312", "123456");
                Assert.IsTrue(login);
                bool login2 = auService.CheckLogin("123412312312", "123456");
                Assert.IsFalse(login2);
                bool login3 = auService.CheckLogin("12312312312", "3422");
                Assert.IsFalse(login3);
                bool login4 = auService.CheckLogin("3242323423", "3422");
                Assert.IsFalse(login4);

                auService.MarkDeleted(id);
            }
            catch (Exception ex)
            {
                auService.MarkDeleted(id);
                throw ex;
            }
        }
Ejemplo n.º 23
0
        public ActionResult List(long typeId, int pageIndex = 1)
        {
            //因为AuthorizFilter做了是否登录的检查,因此这里不会取不到uerid
            long userId = (long)AdminHelper.GetUserId(HttpContext);
            var  user   = AdminUserService.GetById(userId);

            if (user.CityId == null)
            {
                //TODO如果“总部不能***”的操作很多,也可以定义成一个AuthorizeFilter
                //最好用FilterAttribute的方式标注,这样对其他的不涉及这个问题的地方效率高
                //立即实现
                return(View("ERROR", (object)"总部不能进行房源管理"));
            }
            int  pageSize   = 4;
            var  houses     = HouseService.GetPagedData((long)user.CityId, typeId, pageSize, (pageIndex - 1) * pageSize);
            long totalCount = HouseService.GetTotalCount((long)user.CityId, typeId);

            ViewBag.totalCount = totalCount;
            ViewBag.pageIndex  = pageIndex;
            ViewBag.typeId     = typeId;
            ViewBag.pageSize   = pageSize;
            return(View(houses));
        }
Ejemplo n.º 24
0
        [ValidateInput(false)]  //允许输入的内容包含标签 脚本 解决 从客户端中检测到有潜在危险的 Request.Form 值错误
        public ActionResult Edit(HouseEditModel model)
        {
            long userId = (long)AdminHelper.GetUserId(HttpContext);
            var  user   = AdminUserService.GetById(userId);

            if (user.CityId == null)
            {
                return(View("ERROR", (object)"总部不能进行房源管理"));
            }
            var house = HouseService.GetById(model.HouseId);

            house.Address          = model.Address;
            house.Area             = model.Area;
            house.AttachmentIds    = model.AttachmentIds;
            house.CheckInDateTime  = model.CheckInDateTime;
            house.CommunityId      = model.CommunityId;
            house.Description      = model.Description;
            house.DecorateStatusId = model.DecorateStatusId;
            house.Direction        = model.Direction;
            house.FloorIndex       = model.FloorIndex;
            house.LookableDateTime = model.LookableDateTime;
            house.MonthRent        = model.MonthRent;
            house.OwnerName        = model.OwnerName;
            house.OwnerPhoneNum    = model.OwnerPhoneNum;
            house.RoomTypeId       = model.RoomTypeId;
            house.StatusId         = model.StatusId;
            house.TypeId           = model.TypeId;
            house.TotalFloorCount  = model.TotalFloorCount;
            HouseService.Update(house);
            //编辑房源后,也生成静态页
            CreateStaticPages(model.HouseId);
            return(Json(new AjaxResult()
            {
                Status = "ok"
            }));
        }
Ejemplo n.º 25
0
        public ActionResult Edit(int id)
        {
            var adminUser = AdminUserService.GetById(id);

            if (adminUser == null)
            {
                return(View("Error", (object)"id指定的管理员不存在"));
            }
            var roles         = RoleService.GetAll();
            var adminUserRole = RoleService.GetByAdminUserId(adminUser.Id);
            var city          = CityService.GetAll().ToList();

            city.Insert(0, new DTO.CityDTO {
                Name = "总部", Id = 0
            });

            AdminUserEditGetModel model = new AdminUserEditGetModel();

            model.AdminUser     = adminUser;
            model.AdminUserRole = adminUserRole;
            model.Roles         = roles;
            model.Citys         = city;
            return(View(model));
        }