public IActionResult CreateSales(Sales sale) { string isoJson = JsonConvert.SerializeObject(sale); // {"Details":"Application started.","LogDate":"2009-02-15T00:00:00Z"} JsonSerializerSettings microsoftDateFormatSettings = new JsonSerializerSettings { DateFormatHandling = DateFormatHandling.MicrosoftDateFormat }; string microsoftJson = JsonConvert.SerializeObject(sale, microsoftDateFormatSettings); // {"Details":"Application started.","LogDate":"\/Date(1234656000000)\/"} string javascriptJson = JsonConvert.SerializeObject(sale, new JavaScriptDateTimeConverter()); // {"Details":"Application started.","LogDate":new Date(1234656000000)} try { Console.WriteLine("adding"); // _context.Sales.Add(sale); _context.Sales.Add(new Sales { Productid = sale.Productid, Customerid = sale.Customerid, Storeid = sale.Storeid, Datesolde = sale.Datesolde.Date }); _context.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); return(Json(new { Data = "Create Customer Failed", c = sale })); } return(Json(new { Data = "Customer created", c = sale })); }
public JsonResult CreateCustomer(Customer customer) { try { Console.WriteLine("adding"); _context.Customer.Add(new Customer { Name = customer.Name, Address = customer.Address }); _context.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); return(Json(new { Data = "Create Customer Failed", c = customer })); } return(Json(new { Data = "Customer created", c = customer })); }
public JsonResult CreateProduct(Product product) { try { Console.WriteLine("adding"); _context.Product.Add(new Product { Name = product.Name, Price = product.Price }); _context.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); return(Json(new { Data = "Create Product Failed", c = product })); } return(Json(new { Data = "Product created", c = product })); }
public JsonResult CreateStore(Store store) { try { Console.WriteLine("adding"); _context.Store.Add(new Store { Name = store.Name, Address = store.Address }); _context.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); return(Json(new { Data = "Create Customer Failed", c = store })); } return(Json(new { Data = "Customer created", c = store })); }