Ejemplo n.º 1
0
        public virtual ActionResult DeleteUser(User user, string confirmButton, string returnUrl)
        {
            var context = ModelFactory.GetUnitOfWork();
            var mRepo = ModelFactory.GetRepository<IMemberRepository>(context);
            var member = mRepo.GetMember(user.UserName);
            if (member == null)
            {
                TempData[MiscHelpers.TempDataConstants.Info] = Worki.Resources.Views.Admin.AdminString.UserNotFound;
                return RedirectToAction(MVC.Admin.Member.IndexUser());
            }
            else
            {
                try
                {
                    mRepo.Delete(member.MemberId);
                    context.Commit();
                }
                catch (Exception ex)
                {
                    _Logger.Error("", ex);
                    context.Complete();
                }

                TempData[MiscHelpers.TempDataConstants.Info] = Worki.Resources.Views.Admin.AdminString.UserHaveBeenDel;

                return Redirect(returnUrl);
            }
        }
Ejemplo n.º 2
0
        public virtual ActionResult CreateMemberApi(User formModel)
        {
            if (ModelState.IsValid)
            {
                var context = ModelFactory.GetUnitOfWork();
                var mRepo = ModelFactory.GetRepository<IMemberRepository>(context);
                try
                {
                    var member = mRepo.GetMember(formModel.UserName);
                    if (member == null)
                        throw new NullReferenceException();

                    member.MemberMainData.ApiKey = Guid.NewGuid().ToString();
                    context.Commit();

                    return RedirectToAction(MVC.Admin.Member.MemberWithApi());
                }
                catch (Exception ex)
                {
                    context.Complete();
                    ModelState.AddModelError("", ex.Message);
                }
            }
            return View(formModel);
        }