Example #1
0
        }                                                 //End public void Delete_byUSR_RUID(string id)

        public void Create_prepare(CPARChatnotify_DetailVM poViewModel)
        {
            string vsMsgErr = "";

            try
            {
                CPARChatnotify oModel = new CPARChatnotify();
                //Map Form Data
                Mapper.CreateMap <CPARChatnotify_DetailVM, CPARChatnotify>();
                oModel = Mapper.Map <CPARChatnotify_DetailVM, CPARChatnotify>(poViewModel);
                //Set Field Header
                oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                //Set DTA_STS
                oModel.DTA_STS = valFLAG.FLAG_CRUDOPT_CREATE;
                this.oModel    = oModel;
            }                                             //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        }                                                 //End public void Create
Example #2
0
        }                                                 //End public void Create

        public void Update(CPARChatnotify_DetailVM poViewModel)
        {
            string vsMsgErr = "";

            try
            {
                using (var db = new DBMAINContext())
                {
                    CPARChatnotify oModel = db.CPARChatnotifys.AsNoTracking().SingleOrDefault(fld => fld.RUID == poViewModel.RUID);
                    //Map Form Data
                    Mapper.CreateMap <CPARChatnotify_DetailVM, CPARChatnotify>();
                    oModel = Mapper.Map <CPARChatnotify_DetailVM, CPARChatnotify>(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.UPDATE);
                    //Process CRUD
                    db.Entry(oModel).State = EntityState.Modified;
                    db.SaveChanges();
                }                                         //End using
            }                                             //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        }                                                 //End public void Update
Example #3
0
        }                               //End public CPARChatnotifyCRUD()

        public void Create(CPARChatnotify_DetailVM poViewModel)
        {
            string vsMsgErr = "";

            try
            {
                using (var db = new DBMAINContext())
                {
                    CPARChatnotify oModel = new CPARChatnotify();
                    //Map Form Data
                    Mapper.CreateMap <CPARChatnotify_DetailVM, CPARChatnotify>();
                    oModel = Mapper.Map <CPARChatnotify_DetailVM, CPARChatnotify>(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                    //Set DTA_STS
                    oModel.DTA_STS = valFLAG.FLAG_CRUDOPT_CREATE;
                    //Process CRUD
                    db.CPARChatnotifys.Add(oModel);
                    db.SaveChanges();
                }                                         //End using
            }                                             //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        }                                                 //End public void Create
Example #4
0
        }                         //End public CPARChatCRUD()

        public void Create(CPARChat_DetailVM poViewModel)
        {
            string vsMsgErr         = "";
            string sSENDER_ROLERUID = hlpConfig.SessionInfo.getAppRoleRUID();

            try
            {
                using (var db = new DBMAINContext())
                {
                    CPARChat oModel = new CPARChat();
                    //Map Form Data
                    Mapper.CreateMap <CPARChat_DetailVM, CPARChat>();
                    oModel = Mapper.Map <CPARChat_DetailVM, CPARChat>(poViewModel);
                    //Set Field Header
                    oModel.setFIELD_HEADER(hlpFlags_CRUDOption.CREATE);
                    //Set DTA_STS
                    oModel.DTA_STS = valFLAG.FLAG_CRUDOPT_CREATE;
                    //Set field
                    oModel.CPAR_RUID     = poViewModel.CPAR_RUID;
                    oModel.USR_RUID      = oModel.ADTRL_USR;
                    oModel.CHAT_DESC_FMT = oModel.CHAT_DESC_PLAIN;
                    //Add model to save
                    db.CPARChats.Add(oModel);

                    CPARChatnotifyCRUD oCRUD_notify = new CPARChatnotifyCRUD();
                    //Send Notification to AUDITEE
                    if (sSENDER_ROLERUID == valFLAG.FLAG_ROLE_CPAR_ADMIN)
                    {
                        CPARDS oDS_CPAR  = new CPARDS();
                        var    oQRY_cpar = oDS_CPAR.getData(oModel.CPAR_RUID);
                        CPARChatnotify_DetailVM oVM_notify = new CPARChatnotify_DetailVM();
                        oVM_notify.CPARCHAT_RUID = oModel.RUID;
                        oVM_notify.USR_RUID      = oQRY_cpar.AUDITEE_USRRUID; //oQRY_cpar.AUDITEE_RUID;
                        oCRUD_notify.Create_prepare(oVM_notify);
                        CPARChatnotify oModel_notify = oCRUD_notify.oModel;
                        //Add model to save
                        db.CPARChatnotifys.Add(oModel_notify);
                    } //End if (sSENDER_ROLERUID != valFLAG.FLAG_ROLE_CPAR_ADMIN)

                    //Send Notification to CPAR_ADMIN
                    if (sSENDER_ROLERUID != valFLAG.FLAG_ROLE_CPAR_ADMIN)
                    {
                        UserDS oDS_user  = new UserDS();
                        var    oQRY_user = oDS_user.getDatalist(valFLAG.FLAG_ROLE_CPAR_ADMIN);
                        foreach (var item in oQRY_user)
                        {
                            CPARChatnotify_DetailVM oVM_notifyX = new CPARChatnotify_DetailVM();
                            oVM_notifyX.CPARCHAT_RUID = oModel.RUID;
                            oVM_notifyX.USR_RUID      = item.RUID;
                            oCRUD_notify.Create_prepare(oVM_notifyX);
                            CPARChatnotify oModel_notifyX = oCRUD_notify.oModel;
                            //Add model to save
                            db.CPARChatnotifys.Add(oModel_notifyX);
                        } //End foreach (var item in oQRY_user)
                    }     //End if (sSENDER_ROLERUID == valFLAG.FLAG_ROLE_CPAR_ADMIN)


                    //Process CRUD
                    db.SaveChanges();
                    this.RUID = oModel.RUID;
                }                                         //End using
            }                                             //End try
            catch (Exception e) { vsMsgErr = e.Message; } //End catch
        }                                                 //End public void Create