Esempio n. 1
0
        public IHttpActionResult PostRequest([FromBody] RequestViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("invalid request"));
            }
            using (var context = new EquipEntities())
            {
                try
                {
                    var result = context.INSERT_REQUEST(model.IDEmployee, model.UserName, model.EquipmentType);
                    if (result == 1)
                    {
                        context.SaveChanges();
                        return(Ok());
                    }

                    else
                    {
                        return(BadRequest("server error"));
                    }
                }
                catch (Exception ex)
                {
                    return(BadRequest(ex.Message));
                }
            }
        }
Esempio n. 2
0
 public IHttpActionResult GetListOfTypeEquipment()
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("invalid request"));
     }
     using (var context = new EquipEntities())
     {
         try
         {
             var           types = context.EQUIPMENTs.GroupBy(s => s.Type).ToList();
             List <string> Types = new List <string>();
             foreach (var item in types)
             {
                 Types.Add(item.Key);
             }
             return(Ok(Types));
         }
         catch (Exception ex)
         {
             return(BadRequest(ex.Message));
         }
     }
 }