public HttpResponseMessage GetCustomerByCustomerId(int customerId) { try { BOCustomers customer = new BOCustomers(); var customers = new customers(); customers = customer.GetCustomerByCustomerId(customerId); return(Request.CreateResponse(HttpStatusCode.OK, customers)); } catch (Exception e) { ErrorMessage mensaje = new ErrorMessage("2.1", "Exception to get customers - " + e.GetBaseException().Message, e.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, mensaje)); } }
public HttpResponseMessage UploadLogo() { var filePath = "~/Logos/"; customers customer = new customers(); customers customers; BOUsers user = new BOUsers(); var logo = HttpContext.Current.Request.Files.AllKeys.Any(); //get paramaetes shipment files var customerId = HttpContext.Current.Request.Params["model.customerId"]; try { if (HttpContext.Current.Request.Files.AllKeys.Any()) { // Get the uploaded image from the Files collection var httpPostedFile = HttpContext.Current.Request.Files["UploadLogo"]; if (httpPostedFile != null) { var file_name = httpPostedFile.FileName; // Get the complete file path string fileSave = DateTime.Now.ToString("yyyyMMddHHmmss") + file_name; // if the directory doesn't exist - create it. if (!Directory.Exists(HttpContext.Current.Server.MapPath(filePath + "/" + customerId))) { Directory.CreateDirectory(HttpContext.Current.Server.MapPath(filePath + "/" + customerId)); string path = filePath + "/" + customerId + "/" + fileSave; httpPostedFile.SaveAs(HttpContext.Current.Server.MapPath(path)); } else { string path = filePath + "/" + customerId + "/" + fileSave; httpPostedFile.SaveAs(HttpContext.Current.Server.MapPath(path)); } customer.logo = fileSave; } //map de parametes to model shipment attachment customer.customerId = Convert.ToDecimal(customerId); } BOCustomers custom = new BOCustomers(); customer.customerId = Convert.ToDecimal(customerId); customers = custom.GetCustomerByCustomerId(Convert.ToInt32(customerId)); customers.logo = customer.logo; customers = user.updateProfile(customers); return(Request.CreateResponse(HttpStatusCode.OK, customers)); } catch (Exception e) { ErrorMessage mensaje = new ErrorMessage("2.1", "Exception to update Profile - " + e.GetBaseException().Message, e.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, mensaje)); } }