Esempio n. 1
0
        public ActionResult GroupsCreate(Group groups)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_repository.Search<Group>(p => p.Name == groups.Name.Trim()).Any())
                    {
                        groups.Id = Guid.NewGuid();
                        groups.Maker = User.Identity.GetUserName();
                        groups.OsysDateTime = DateTime.Now;
                        groups.EditDateTime = DateTime.Now;
                        groups.Status = MyEnums.StatusOptions.Added;
                        _repository.SaveNew(groups);
                        _sharedCls.LogAudit(User.Identity.GetUserName(), "Created", Request.UserHostName,
                            "Created Group" + groups.Name, "Created", "Groups");

                    }
                    else
                    {
                        ModelState.AddModelError("", "Group Already Exists");
                        return View();
                    }
                }

                return RedirectToAction("GroupsIndex");
            }
            catch (Exception ex)
            {
                return View();
            }
        }
Esempio n. 2
0
        public ActionResult GroupsEdit(Group groups)
        {
            try
            {
                if (ModelState.IsValid)
                {

                        Group newGroup = _repository.Find<Group>(groups.Id);
                        newGroup.Name = groups.Name;
                        newGroup.Description = groups.Description;
                        newGroup.Maker = User.Identity.GetUserName();
                        newGroup.Status = MyEnums.StatusOptions.Added;
                        _repository.SaveUpdate(newGroup);
                        _sharedCls.LogAudit(User.Identity.GetUserName(), "Edited", Request.UserHostName,
                            "Edited Group" + groups.Name, "Edited", "Groups");

                }

                return RedirectToAction("GroupsIndex");
            }
            catch
            {
                return View();
            }
        }