public void Delete(string id) { try { LoggerUtils.WriteLog("PlansController : DELETE - request received"); planService.Delete(id); } catch (Exception ex) { LoggerUtils.WriteLog("ERROR : PlansController : " + ex.Message + "\r" + "InnerException : " + ex.InnerException); } }
public void Put([FromBody] MachineModel machine) { try { LoggerUtils.WriteLog("MachinesController : PUT - request received"); machineService.Update(machine); } catch (Exception ex) { LoggerUtils.WriteLog("ERROR : MachinesController : " + ex.Message + "\r" + "InnerException : " + ex.InnerException); } }
public void Put([FromBody] CustomerModel customer) { try { LoggerUtils.WriteLog("CustomersController : PUT request received"); customerService.Update(customer); } catch (Exception ex) { LoggerUtils.WriteLog("ERROR : CustomersController : " + ex.Message + "\r" + "InnerException : " + ex.InnerException); } }
public void Put([FromBody] PlanModel plan) { try { LoggerUtils.WriteLog("PlansController : PUT - request received"); plan.LastUpdated = DateTime.Now; planService.Update(plan); } catch (Exception ex) { LoggerUtils.WriteLog("ERROR : PlansController : " + ex.Message + "\r" + "InnerException : " + ex.InnerException); } }
public HttpResponseMessage GetAll() { try { LoggerUtils.WriteLog("PlansController : GET ALL - request received"); var plans = planService.GetAll(); return(Request.CreateResponse(HttpStatusCode.OK, plans)); } catch (Exception ex) { LoggerUtils.WriteLog("ERROR : PlansController : " + ex.Message + "\r" + "InnerException : " + ex.InnerException); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public IHttpActionResult Authenticate([FromBody] LoginRequest login) { var loginResponse = new LoginResponse(); LoginRequest loginRequest = new LoginRequest(); loginRequest.Username = login.Username; loginRequest.Password = login.Password; IHttpActionResult response; HttpResponseMessage responseMsg = new HttpResponseMessage(); bool isUsernamePasswordValid = false; try { if (login != null) { // For production using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, ConfigurationManager.AppSettings["ADDomainName"])) { isUsernamePasswordValid = pc.ValidateCredentials(loginRequest.Username, loginRequest.Password); } //isUsernamePasswordValid = loginRequest.Password == "admin" ? true : false; } if (isUsernamePasswordValid) { string token = CreateToken(loginRequest.Username); LoggerUtils.WriteLog("New connection to BackOffice : " + loginRequest.Username); return(Ok <string>(token)); } else { loginResponse.ResponseMessage.StatusCode = System.Net.HttpStatusCode.Unauthorized; response = ResponseMessage(loginResponse.ResponseMessage); LoggerUtils.WriteLog("Connection failed to BackOffice : " + loginRequest.Username); return(response); } } catch (Exception ex) { LoggerUtils.WriteLog("ERROR : AuthController : " + ex.Message + "\r" + "InnerException : " + ex.InnerException); loginResponse.ResponseMessage.StatusCode = System.Net.HttpStatusCode.InternalServerError; response = ResponseMessage(loginResponse.ResponseMessage); return(response); } }
// GET api/<controller> public HttpResponseMessage Get(string id) { try { LoggerUtils.WriteLog("MachinesController : GET BY ID - request received"); var machine = machineService.Get(id); if (machine != null) { return(Request.CreateResponse(HttpStatusCode.OK, machine)); } return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Machine not found for provided id.")); } catch (Exception ex) { LoggerUtils.WriteLog("ERROR : MachinesController : " + ex.Message + "\r" + "InnerException : " + ex.InnerException); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }