public IHttpActionResult Post([FromBody] Product product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Products.Add(product); db.SaveChanges(); return(Ok(product)); }
// POST api/<controller> public IHttpActionResult Post([FromBody] AddUser user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } User us = new User { login = user.Login, password = user.Password }; db.Users.Add(us); UsersInfo usf = new UsersInfo { FirstName = user.FirstName, SecondName = user.SecondName, login = user.Login, address = user.Address, BornDate = Convert.ToDateTime(user.BornDate), mail = user.Mail, number = user.Number, Patronomyc = user.Patronomyc }; db.UsersInfoes.Add(usf); db.SaveChanges(); return(Ok(User)); }
// POST api/<controller> public IHttpActionResult Post([FromBody] Order order) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Orders.Add(order); db.SaveChanges(); return(Ok(order)); }
public IHttpActionResult Put([FromBody] UserInf user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } UsersInfo usr = db.UsersInfoes.Find(user.Login); usr.mail = user.Mail; usr.number = user.Number; usr.address = user.Address; db.SaveChanges(); return(Ok(user)); }
// POST api/<controller> public IHttpActionResult Post([FromBody] Orders order) { Order orders = new Order { Login = order.Login, Delivery = order.DeliveryMethod, Payment = order.PaymentMethod, Price = order.Price, Commentary = order.Comment, Status = 1, }; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Orders.Add(orders); db.SaveChanges(); return(Ok(orders)); }