Exemplo n.º 1
0
        public IHttpActionResult PutDrugSuply(int id, DrugSuply drugSuply)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != drugSuply.Id)
            {
                return(BadRequest());
            }

            db.Entry(drugSuply).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DrugSuplyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 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);
        }