Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("ZactionId,action,report,active")] Zaction zaction)
        {
            if (id != zaction.ZactionId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(zaction);
                    TempData["Alert"] = String.Format("Saved Changes to Action: {0}", zaction.action);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ZactionExists(zaction.ZactionId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(zaction));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("ZactionId,action,report,active")] Zaction zaction)
        {
            if (ModelState.IsValid)
            {
                _context.Add(zaction);
                TempData["Alert"] = String.Format("Added Action: {0}", zaction.action);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(zaction));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Get all user's rights
 /// </summary>
 /// <param name="userId">User's Id</param>
 /// <returns></returns>
 public List<Zaction> GetRights(Guid userId)
 {
     try
     {
         var a = from s in _db.Pol_UserRights
                 join u in _db.Pol_Users on s.UserId equals u.Id
                 join r in _db.Pol_Dictionarys on s.RightId equals r.Id
                 where s.UserId == userId
                 select new
                 {
                     RightCode = r.Code,
                     RightName = r.Text,
                     RightDescript = r.Note,
                     s.Add,
                     s.Edit,
                     s.Delete,
                     s.Default,
                     s.Print,
                     s.Access,
                     s.Full,
                     s.None
                 };
         var b = from s in _db.Pol_RoleRights
                 join r in _db.Pol_Dictionarys on s.RightId equals r.Id
                 join ur in _db.Pol_UserRoles on s.RoleId equals ur.RoleId
                 join u in _db.Pol_Users on ur.UserId equals u.Id
                 where ur.User.Id == userId
                 select new
                 {
                     RightCode = r.Code,
                     RightName = r.Text,
                     RightDescript = r.Note,
                     s.Add,
                     s.Edit,
                     s.Delete,
                     s.Default,
                     s.Print,
                     s.Access,
                     s.Full,
                     s.None
                 };
         var tmp = a.Union(b);
         var lst = new List<Zaction>();
         foreach (var res in tmp)
         {
             var z = new Zaction()
             {
                 Code = res.RightCode,
                 Add = res.Add,
                 Edit = res.Edit,
                 Delete = res.Delete,
                 Default = res.Default,
                 Print = res.Print,
                 Access = res.Access,
                 Full = res.Full,
                 None = res.None
             };
             lst.Add(z);
         }
         return lst;
     }
     catch { return null; }
 }