public IHttpActionResult EditFormData(int id, [FromBody] EquipmentModels.Edit Equipment) { JavaScriptSerializer js = new JavaScriptSerializer(); string logForm = "Form : " + js.Serialize(Equipment); string logAPI = "[Put] " + Request.RequestUri.ToString(); if (!ModelState.IsValid || Equipment == null) { Startup._sfAppLogger.Warn(logAPI + " || Input Parameter not expected || " + logForm); return(BadRequest("Invalid data")); } try { EquipmentModels equipmentModel = new EquipmentModels(); equipmentModel.updateEquipment(id, Equipment); return(Ok()); } catch (Exception ex) { StringBuilder logMessage = LogUtility.BuildExceptionMessage(ex); logMessage.AppendLine(logForm); Startup._sfAppLogger.Error(logAPI + logMessage); return(InternalServerError(ex)); } }
public IHttpActionResult AddFormData([FromBody] EquipmentModels.Edit Equipment) { string logForm = "Form : " + Startup._jsSerializer.Serialize(Equipment); string logAPI = "[Post] " + Request.RequestUri.ToString(); if (!ModelState.IsValid || Equipment == null) { Startup._sfAppLogger.Warn(logAPI + " || Input Parameter not expected || " + logForm); return(BadRequest("Invalid data")); } try { EquipmentModels equipmentModel = new EquipmentModels(); int newEquipmentId = equipmentModel.addEquipment(Equipment); return(Json(new { id = newEquipmentId })); } catch (Exception ex) { StringBuilder logMessage = LogUtility.BuildExceptionMessage(ex); logMessage.AppendLine(logForm); Startup._sfAppLogger.Error(logAPI + logMessage); return(InternalServerError(ex)); } }