Example #1
0
        // GET api/<controller>/5
        public TEEscalationMatrixModel Get(int id)
        {
            TEESCALATIONMATRIX item = db.TEESCALATIONMATRIces.Find(id);

            TEEscalationMatrixModel model = new TEEscalationMatrixModel();

            TETransformEntityNModel translator = new TETransformEntityNModel();

            model = translator.TransformAtoB(item, model);

            if (item.QueueID != null)
            {
                TEQueue q = db.TEQueues.Find(item.QueueID.Value);
                if (q != null)
                {
                    model.Queue = new TEQueue
                    {
                        Uniqueid  = q.Uniqueid,
                        QueueName = q.QueueName,
                        QueueID   = q.QueueID,
                    }
                }
                ;
            }
            if (item.ManagerID != null)
            {
                TEEmpBasicInfo mgr = db.TEEmpBasicInfoes.Find(item.ManagerID.Value);
                if (mgr != null)
                {
                    model.Manager = new TEEmpBasicInfo
                    {
                        Uniqueid      = mgr.Uniqueid,
                        FirstName     = mgr.FirstName,
                        LastName      = mgr.LastName,
                        Mobile        = mgr.Mobile,
                        OfficialEmail = mgr.OfficialEmail,
                    }
                }
                ;
            }
            if (item.Priority != null)
            {
                int            picklistid = Convert.ToInt32(item.Priority);
                TEPickListItem p          = db.TEPickListItems.Find(picklistid);
                if (p != null)
                {
                    model.PriorityName = p.Description;
                }
            }

            return(model);
        }
Example #2
0
        // GET api/<controller>
        public IEnumerable <TEEscalationMatrixModel> Get()
        {
            db.Configuration.ProxyCreationEnabled = false;
            List <TEESCALATIONMATRIX> list = db.TEESCALATIONMATRIces.Where(x => x.IsDeleted == false).ToList();

            List <TEEscalationMatrixModel> result = new List <TEEscalationMatrixModel>();

            foreach (var item in list)
            {
                TEEscalationMatrixModel model = new TEEscalationMatrixModel();

                TETransformEntityNModel translator = new TETransformEntityNModel();

                model = translator.TransformAtoB(item, model);

                if (item.QueueID != null)
                {
                    TEQueue q = db.TEQueues.Find(item.QueueID.Value);
                    if (q != null)
                    {
                        model.Queue = new TEQueue
                        {
                            Uniqueid  = q.Uniqueid,
                            QueueName = q.QueueName,
                            QueueID   = q.QueueID,
                        }
                    }
                    ;
                }
                if (model.Queue == null)
                {
                    model.Queue = new TEQueue();
                }
                if (item.ManagerID != null)
                {
                    TEEmpBasicInfo mgr = db.TEEmpBasicInfoes.Find(item.ManagerID.Value);
                    if (mgr != null)
                    {
                        model.Manager = new TEEmpBasicInfo
                        {
                            Uniqueid      = mgr.Uniqueid,
                            FirstName     = mgr.FirstName,
                            LastName      = mgr.LastName,
                            Mobile        = mgr.Mobile,
                            OfficialEmail = mgr.OfficialEmail,
                        }
                    }
                    ;
                }
                if (model.Manager == null)
                {
                    model.Manager = new TEEmpBasicInfo();
                }
                if (item.Priority != null)
                {
                    int            picklistid = Convert.ToInt32(item.Priority);
                    TEPickListItem p          = db.TEPickListItems.Find(picklistid);
                    if (p != null)
                    {
                        model.PriorityName = p.Description;
                    }
                }
                result.Add(model);
            }
            return(result);
        }