Exemplo n.º 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);
        }
Exemplo n.º 2
0
        // POST api/<controller>
        public TEESCALATIONMATRIX Post(TEESCALATIONMATRIX value)
        {
            db.Configuration.ProxyCreationEnabled = false;
            TEESCALATIONMATRIX result = value;

            if (!(value.Uniqueid + "".Length > 0))
            {
                //Create
                result.CreatedOn      = System.DateTime.Now;
                result.LastModifiedOn = System.DateTime.Now;
                result = db.TEESCALATIONMATRIces.Add(value);
            }
            else
            {
                //Edit
                db = new TEHRIS_DevEntities();
                db.TEESCALATIONMATRIces.Attach(value);
                foreach (System.Reflection.PropertyInfo item in result.GetType().GetProperties())
                {
                    string propname = item.Name;
                    if (propname.ToLower() == "createdon")
                    {
                        continue;
                    }
                    object propValue = item.GetValue(value);
                    if (propValue != null || Convert.ToString(propValue).Length != 0)
                    {
                        db.Entry(value).Property(propname).IsModified = true;
                    }
                }

                value.LastModifiedOn = System.DateTime.Now;
                db.Entry(value).Property(x => x.LastModifiedOn).IsModified = true;
            }

            db.SaveChanges();
            return(db.TEESCALATIONMATRIces.Find(value.Uniqueid));
        }