예제 #1
0
        public bool Add(int id, PhanQuyenNVViewModel model)
        {
            if (model.Quyens?.Count > 0)
            {
                foreach (var idrole in model.Quyens)
                {
                    var grouprole = new TBL_GROUP_ROLE
                    {
                        ID_GROUP = id,
                        ID_ROLE  = idrole,
                        ACTIVATE = true
                    };
                    context.TBL_GROUP_ROLEs.Add(grouprole);
                }
            }

            context.SaveChanges();
            return(true);
        }
예제 #2
0
        public ActionResult Create(int id, PhanQuyenNVViewModel collection)
        {
            try
            {
                // TODO: Add insert logic here

                if (ModelState.IsValid)
                {
                    PQService.Add(id, collection);

                    //return RedirectToAction("Index");

                    return(RedirectToAction("Index", "PhanNhomNV"));
                }
                return(View(collection));
            }
            catch (Exception ex)
            {
                string er = ex.Message;
                return(View());
            }
        }