/// <summary>
        /// 保存人员数据
        /// </summary>
        /// <param name="perVM"></param>
        /// <returns></returns>
        public async Task <IActionResult> Save([Bind("ID,IsNew,UserName,Name,Description,MobileNumber,QQ,UserAddress,School")] ApplicationUserVM userVM)
        {
            var hasDuplicateNamePerson = await _userExtension.HasInstanceAsyn(x => x.Name == userVM.Name);

            if (hasDuplicateNamePerson && userVM.IsNew)     //判断是否已存在该人员
            {
                ModelState.AddModelError("", "人员名重复,无法添加"); //添加指定的错误信息
                return(View("~/Views/BusinessOrganization/Person/CreateOrEdit.cshtml", userVM));
            }
            var user = new ApplicationUser();

            if (!userVM.IsNew)
            {
                user = await _userExtension.GetSingleAsyn(x => x.Id == userVM.ID.ToString());
            }
            userVM.MapToOm(user);
            if (userVM.IsNew)
            {
                _userExtension.AddAndSave(user);
            }
            else
            {
                _userExtension.EditAndSave(user);
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 禁用社团
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> ProhibitAnAssociation(Guid id)
        {
            var entity = await _anAssociationExtension.GetSingleAsyn(x => x.ID == id);

            if (entity == null)
            {
                return(Json(new { isOK = false, meesage = "不存在该社团" }));
            }
            if (!entity.IsDisable)
            {
                return(Json(new { isOK = false, meesage = "该社团已被禁用" }));
            }
            entity.IsDisable = false;
            _anAssociationExtension.EditAndSave(entity);
            return(Json(new { isOK = true, meesage = "成功禁用社团:" + entity.Name }));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Index()
        {
            var user = User.Claims.FirstOrDefault();

            if (user == null)
            {
                return(RedirectToAction("Error"));
            }
            var UserInfo = await _userExtension.GetSingleAsyn(x => x.Id == user.Value);

            if (UserInfo.Power == AnJurisdiction.Ordinary)
            {
                return(RedirectToAction("Error"));
            }
            var userCollection = await _userExtension.GetAll().Include(x => x.Avatar).OrderByDescending(x => x.RegisterTime).ToListAsync();

            var users    = userCollection.Take(10).ToList();
            var userList = new List <ApplicationUserVM>();

            foreach (var item in users)
            {
                userList.Add(new ApplicationUserVM(item));
            }
            ViewBag.Users          = userCollection.Count();
            ViewBag.AnAssociations = (await _anAssociationExtension.GetAll().ToListAsync()).Count();
            ViewBag.ActivityTerms  = (await _activityTermExtension.GetAll().ToListAsync()).Count();
            return(PartialView("Index", userList));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 禁止活动
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> ProhibitActivityTrem(Guid id)
        {
            var entity = await _activityTermExtension.GetSingleAsyn(x => x.ID == id);

            if (entity == null)
            {
                return(Json(new { isOK = false, message = "不存在该活动" }));
            }
            if (!entity.IsDisable)
            {
                return(Json(new { isOK = false, message = "该活动已被禁止" }));
            }
            entity.IsDisable = false;
            _activityTermExtension.EditAndSave(entity);
            return(Json(new { isOK = true, message = "成功禁用活动:" + entity.Name }));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 保存爱好数据
        /// </summary>
        /// <param name="perVM"></param>
        /// <returns></returns>
        public async Task <IActionResult> Save([Bind("ID,Name,Description,SortCode")] HobbyVM hobbyVM)
        {
            if (hobbyVM.Name == "")
            {
                ModelState.AddModelError("", "爱好名称为空,无法添加");//添加指定的错误信息
            }
            var hobby = await _hobbyExtension.GetSingleAsyn(x => x.ID == hobbyVM.ID);

            if (hobby == null)
            {
                hobby = new Hobby();
                hobbyVM.MapToHb(hobby);
                _hobbyExtension.AddAndSave(hobby);
            }
            else
            {
                hobbyVM.MapToHb(hobby);
                _hobbyExtension.EditAndSave(hobby);
            }
            return(RedirectToAction("Index"));
        }