Exemple #1
0
        public ActionResult Create(CommViewModel cvm)
        {
            try {
                // TODO: Add insert logic here
                if (cvm.Message.Trim().Length > 0)
                {
                    MSTR_Comms Comms = new MSTR_Comms();
                    Comms.Message   = cvm.Message;
                    Comms.CreatedBy = exLogic.Util.getLoginUserID();
                    ctx.MSTR_Comms.Add(Comms);
                    ctx.SaveChanges();

                    List <MSTR_User> UserList = ctx.MSTR_User.Where(x => x.AccountId == 1).ToList();

                    foreach (MSTR_User Us in UserList)
                    {
                        CommsDetail Cmd = new CommsDetail();
                        Cmd.FromID    = exLogic.Util.getLoginUserID();
                        Cmd.ToID      = Us.UserId;
                        Cmd.MessageID = Comms.MessageID;
                        Cmd.Status    = "NEW";
                        Cmd.CreatedBy = exLogic.Util.getLoginUserID();
                        ctx.CommsDetail.Add(Cmd);
                    }
                    ctx.SaveChanges();
                }
                return(RedirectToAction("Index"));
            } catch (Exception Ex) {
                return(View());
            }
        }
Exemple #2
0
        // GET: COMMS/Create
        public ActionResult Create()
        {
            CommViewModel cvm = new CommViewModel();

            cvm.GetPilotMsgs(0, exLogic.Util.getLoginUserID(), 0);

            return(View(cvm));
        }
Exemple #3
0
        public JsonResult GetPilotMessages(int MessageID = 0, int UserID = 0, int FlightId = 0)
        {
            CommViewModel cvm = new CommViewModel();

            try {
                cvm.GetPilotMsgs(MessageID, UserID, FlightId);
            } catch {
                //no error
            }
            return(Json(cvm.CommsPilotMsgs, JsonRequestBehavior.AllowGet));
        }
        public IEnumerable <CommViewModel> GetAdminFirstFive()
        {
            IEnumerable <Comm>    firstFive    = _repo.Query <Comm>().Include(c => c.SendingUser).ToList().Take(5);
            IList <CommViewModel> listableFive = new List <CommViewModel>();

            foreach (Comm comm in firstFive)
            {
                CommViewModel listable = new CommViewModel
                {
                    Id          = comm.Id,
                    RecId       = comm.RecId,
                    SendingUser = comm.SendingUser.UserName,
                    Subject     = comm.Subject,
                    DateSent    = comm.DateSent,
                    Msg         = comm.Msg,
                    Status      = comm.Status,
                    CommType    = comm.CommType
                };
                listableFive.Add(listable);
            }

            return(listableFive);
        }
        public IList <CommViewModel> GetCommsByUserName(string uid)
        {
            IList <Comm>          userComms = _repo.Query <Comm>().Where(c => c.RecId == uid).Include(c => c.SendingUser).ToList();
            IList <CommViewModel> commView  = new List <CommViewModel>();

            foreach (Comm comm in userComms)
            {
                CommViewModel commViews = new CommViewModel
                {
                    Id            = comm.Id,
                    RecId         = comm.RecId,
                    SendingUser   = comm.SendingUser.UserName,
                    Subject       = comm.Subject,
                    HasBeenViewed = comm.HasBeenViewed,
                    DateSent      = comm.DateSent,
                    Msg           = comm.Msg,
                    Status        = comm.Status,
                    CommType      = comm.CommType
                };
                commView.Add(commViews);
            }
            return(commView);
        }
        //Get all Comms
        public IList <CommViewModel> GetAllComms()
        {
            IList <Comm>          allComms      = _repo.Query <Comm>().Include(c => c.SendingUser).ToList();
            IList <CommViewModel> listableComms = new List <CommViewModel>();

            foreach (Comm comm in allComms)
            {
                CommViewModel listable = new CommViewModel
                {
                    Id            = comm.Id,
                    RecId         = comm.RecId,
                    SendingUser   = comm.SendingUser.UserName,
                    Subject       = comm.Subject,
                    HasBeenViewed = comm.HasBeenViewed,
                    DateSent      = comm.DateSent,
                    Msg           = comm.Msg,
                    Status        = comm.Status,
                    CommType      = comm.CommType
                };
                listableComms.Add(listable);
            }

            return(listableComms);
        }