예제 #1
0
        } //End public void Deactivate

        public void Create_Usermenu(Userrole_DetailVM poViewModel, string psMDLE_RUID)
        {
            string vsMsgErr = "";

            try
            {
                using (var db = new DBMAINContext())
                {
                    ////Map Form Data
                    //List<Userrolemenu_ListVM> oUserrolemenu_ListVM = poViewModel.Userrolemenu_ListVM;
                    //Mapper.CreateMap < List<Userrolemenu_ListVM>, List<Usermenu>>();
                    Mapper.CreateMap<Userrolemenu_ListVM, Usermenu>();
                    List<Usermenu> oModel = Mapper.Map<List<Userrolemenu_ListVM>, List<Usermenu>>(poViewModel.Userrolemenu_ListVM);
                    var oCurrentModel = db.Usermenus.Where(fld => fld.MDLE_RUID == psMDLE_RUID &&
                                        fld.USR_RUID == poViewModel.RUID);
                    //Delete old usermenu
                    foreach (Usermenu item in oCurrentModel) { db.Usermenus.Remove(item); } //End foreach
                    //Add New usermenu
                    foreach (Usermenu item in oModel) {
                        item.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                        item.MDLE_RUID = psMDLE_RUID;
                        item.USR_RUID = poViewModel.RUID;
                        item.IS_GRANTED = hlpGeneral.FlagInfo.getFlagValid();
                        db.Usermenus.Add(item);
                    } //End foreach
                    //Update User (field ROLE_RUID)
                    User oModelUser = db.Users.AsNoTracking().SingleOrDefault(fld => fld.RUID == poViewModel.RUID);
                    //Set Field Header
                    oModelUser.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                    //Set ROLE_RUID
                    oModelUser.ROLE_RUID = poViewModel.ROLE_RUID;
                    //Process CRUD
                    db.Entry(oModelUser).State = EntityState.Modified;
                    
                    //Save Database
                    db.SaveChanges();
                    
                    
                } //End using
            } //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        } //End public void Create
예제 #2
0
        } //End public static User_DetailVM getData(string id = null)
        public Userrole_DetailVM getData_Userrole_Detail(string psUSR_RUID, string psMDLE_RUID)
        {
            Userrole_DetailVM oReturn = null;
            string vsErrMsg = "";

            try
            {
                using (var db = new DBMAINContext())
                {
                    List<string> sNotIn = new List<string>();
                    sNotIn.Add(valDFLT.USR_IDSYSTEM); sNotIn.Add(valDFLT.USR_IDGENERAL); sNotIn.Add(valDFLT.USR_IDDEMO);

                    var oQRY = from tb in db.User_infos
                               where !sNotIn.Contains(tb.USR_ID) && tb.RUID == psUSR_RUID
                               select new Userrole_DetailVM
                               {
                                   RUID = tb.RUID,
                                   DTA_STS = tb.DTA_STS,
                                   BP_STS = tb.BP_STS,
                                   ROLE_RUID = tb.ROLE_RUID,
                                   ROLE_NM = tb.ROLE_NM,
                                   USR_ID = tb.USR_ID,
                                   USR_NM1 = tb.USR_NM1,
                                   RES_NM1 = tb.RES_NM1,
                                   DEPT_NM = tb.DEPT_NM,
                                   BRNCH_NM = tb.BRNCH_NM,
                                   JOB_TITLE_NM = tb.JOB_TITLE_NM,
                                   IMG_SRC = tb.IMG_SRC,
                                   RES_RUID = tb.RES_RUID
                               };
                    oReturn = oQRY.SingleOrDefault();
                    string vsROLE_RUID = "";
                    if (oReturn.ROLE_RUID != null) { vsROLE_RUID = oReturn.ROLE_RUID; }

                    oReturn.Userrolemenu_ListVM = getDatalist_Rolemenu(vsROLE_RUID, psMDLE_RUID, psUSR_RUID);

                } //End using (var = new DbContext())
            } //End try
            catch (Exception e) { vsErrMsg = e.Message; } //End catch
            return oReturn;
        } //End public Userrole_DetailVM getData_Userrole_Detail(string id = null)