public IHttpActionResult PutDrugSuplier(int id, DrugSuplier drugSuplier) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != drugSuplier.Id) { return(BadRequest()); } db.Entry(drugSuplier).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DrugSuplierExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Registration(string login, string password, string repeatPassword, string name, string cardNumber, bool isDistributor) { var db = new XModelContainer(); ActionResult actionResult = Redirect("/Authorization"); if (login.Length > 0 && password.Length > 0 && password == repeatPassword && name.Length > 0 && cardNumber.Length > 0) { if (isDistributor) { DrugDistributor user = new DrugDistributor(); user.Login = login; user.Password = password; user.Name = name; user.SessionKey = cardNumber; db.DrugDistributorSet.Add(user); db.SaveChanges(); } else { DrugSuplier user = new DrugSuplier(); user.Login = login; user.Password = password; user.Name = name; user.SessionKey = cardNumber; db.DrugSuplierSet.Add(user); db.SaveChanges(); } } return(actionResult); }
public IHttpActionResult PostDrugSuplier(DrugSuplier drugSuplier) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.DrugSuplierSet.Add(drugSuplier); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = drugSuplier.Id }, drugSuplier)); }
public IHttpActionResult DeleteDrugSuplier(int id) { DrugSuplier drugSuplier = db.DrugSuplierSet.Find(id); if (drugSuplier == null) { return(NotFound()); } db.DrugSuplierSet.Remove(drugSuplier); db.SaveChanges(); return(Ok(drugSuplier)); }
public IHttpActionResult GetDrugSuplier(int id) { DrugSuplier drugSuplier = db.DrugSuplierSet.Find(id); if (drugSuplier == null) { return(NotFound()); } /* * foreach( var s in drugSuplier.DrugSuplies) * { * s.DrugSuplier = null; * } */ return(Ok(drugSuplier)); }