예제 #1
0
        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));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }
예제 #5
0
        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));
        }