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)); } } }
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)); } } }