public async Task <JsonResult> AddNewVoucher(Voucher voucher) { var res = await _apiContext.PostRequest("Vouchers/", voucher); if (res.Value.ToString() == "400") { Response.StatusCode = 404; return(new JsonResult("Nie można dodać nowego karnetu.")); } return(res); }
public async Task <JsonResult> PostProduct(string product_name, string product_net_price, decimal product_gross_price, int product_quantity, string product_icon, int product_status, List <int> category_id, List <int> club_id) { string result = ""; var product = new Product() { Category_Id = category_id, Club_Id = club_id, Product_Gross_Price = product_gross_price, Product_Icon = product_icon, Product_Status = product_status, Product_Name = product_name, Product_Net_Price = Math.Round(Convert.ToDecimal(product_net_price.Replace(".", ",")), 2), Product_Quantity = product_quantity }; try { JsonResult response = await _apiContext.PostRequest("Products/", product); result = response.Value.ToString(); // zastanowić się w jaki sposób czytać i przekazywać responsy!!! } catch (HttpRequestException e) { result = e.Message; } return(new JsonResult(result)); }
public async Task <JsonResult> AddAsync(Customer customer) { var res = await _apiContext.PostRequest("Customers/", customer); // POWIĄZANIE Z KLUBEM - póki co tymczasowo ustawia return(res); }
public async Task <JsonResult> PostService(List <int> category_id, string service_name, string service_description, decimal service_gross_price, string service_net_price, List <int> service_employees_list, List <int> service_clubs_list, string mon_from, string mon_to, string tue_from, string tue_to, string wen_from, string wen_to, string thu_from, string thu_to, string fri_from, string fri_to, string sat_from, string sat_to, string sun_from, string sun_to, int service_duration) { string result = ""; var service = new Service() { Club_Id = service_clubs_list, Employee_Id = service_employees_list, Service_Description = service_description, Service_Gross_Price = service_gross_price, Service_Net_Price = Math.Round(Convert.ToDecimal(service_net_price.Replace(".", ",")), 2), Service_Name = service_name, Category_Id = category_id, Service_Timelimit_Mon = new List <TimeSpan>() { TimeSpan.Parse(mon_from + ":00"), TimeSpan.Parse(mon_to + ":00") }, Service_Timelimit_Tue = new List <TimeSpan>() { TimeSpan.Parse(tue_from + ":00"), TimeSpan.Parse(tue_to + ":00") }, Service_Timelimit_Wed = new List <TimeSpan>() { TimeSpan.Parse(wen_from + ":00"), TimeSpan.Parse(wen_to + ":00") }, Service_Timelimit_Thu = new List <TimeSpan>() { TimeSpan.Parse(thu_from + ":00"), TimeSpan.Parse(thu_to + ":00") }, Service_Timelimit_Fri = new List <TimeSpan>() { TimeSpan.Parse(fri_from + ":00"), TimeSpan.Parse(fri_to + ":00") }, Service_Timelimit_Sat = new List <TimeSpan>() { TimeSpan.Parse(sat_from + ":00"), TimeSpan.Parse(sat_to + ":00") }, Service_Timelimit_Sun = new List <TimeSpan>() { TimeSpan.Parse(sun_from + ":00"), TimeSpan.Parse(sun_to + ":00") }, Service_Duration = service_duration }; try { JsonResult response = await _apiContext.PostRequest("Services/", service); result = response.Value.ToString(); // zastanowić się w jaki sposób czytać i przekazywać responsy!!! } catch (HttpRequestException e) { result = e.Message; } return(new JsonResult(result)); }
public async Task <JsonResult> Add(Employee employee) { employee.Employee_Added = DateTime.Now; employee.Clubs = new List <EmployeeClub>() { new EmployeeClub { Club_Id = 1 } }; var addedStatus = await _apiContext.PostRequest("Employees", employee); if (addedStatus.Value == "400") { Response.StatusCode = 404; return(new JsonResult("ERR")); } else { Response.StatusCode = 200; return(addedStatus); } }