Esempio n. 1
0
        public async Task <IActionResult> PutProducts(int id, Products products)
        {
            if (id != products.Id)
            {
                return(BadRequest());
            }

            _context.Entry(products).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> PutUser(int id, User user)
        {
            if (id != user.id)
            {
                return(BadRequest());
            }

            _context.Entry(user).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 3
0
        public async Task <IActionResult> PutRequestLine(int id, RequestLine requestLine)
        {
            if (id != requestLine.Id)
            {
                return(BadRequest());
            }

            _context.Entry(requestLine).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                //call recalculate method
                var success = RecalculateRequestTotal(id);
                if (!success)
                {
                    return(this.StatusCode(500));
                }
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RequestLineExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 4
0
        public ActivateResponse ActivateUser(User user)
        {
            ActivateResponse response = new ActivateResponse();

            using (MyDb db = new MyDb())
            {
                try
                {
                    User user2 = db.Users.FirstOrDefault(t => t.Email == user.Email);
                    if (user.ValidationKey == Security.sha512encrypt(user2.ValidationKey))
                    {
                        user2.isActive        = true;
                        db.Entry(user2).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        response.SetError(SystemConstants.ERRORS.SUCCESSFUL);
                    }
                    else
                    {
                        response.SetError(SystemConstants.ERRORS.NOTFOUND);
                    }
                }
                catch (Exception ex)
                {
                    response.SetError(SystemConstants.ERRORS.SYSTEMERROR);
                }
                return(response);
            }
        }
 public ActionResult Edit([Bind(Include = "Id,Brand,Model,Year,Color")] Car car)
 {
     if (ModelState.IsValid)
     {
         db.Entry(car).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(car));
 }
Esempio n. 6
0
 public ActionResult Edit([Bind(Include = "Id,StudentId,Method,Monney,PushUp,Time")] Student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(student));
 }
Esempio n. 7
0
 public ActionResult Edit([Bind(Include = "Xueshengxuehao,Xueshengxingming,Xueshengxingbie")] student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(student));
 }
Esempio n. 8
0
        public SignUpRespone UserSignUp(User user)
        {
            SignUpRespone response = new SignUpRespone();

            try
            {
                using (MyDb db = new MyDb())
                {
                    db.Entry(user).State = System.Data.Entity.EntityState.Added;
                    db.SaveChanges();
                    response.SetError(SystemConstants.ERRORS.SUCCESSFUL);
                }
            }
            catch (Exception ex)
            {
                response.SetError(SystemConstants.ERRORS.SYSTEMERROR);
            }
            return(response);
        }
Esempio n. 9
0
        public RemoveResponse RemoveProductFromBasket(Basket basket)
        {
            RemoveResponse response = new RemoveResponse();

            using (MyDb db = new MyDb())
            {
                try
                {
                    basket = db.Baskets.FirstOrDefault(x => x.Product_ID == basket.Product_ID && x.User_ID == basket.User_ID);
                    db.Entry(basket).State = System.Data.Entity.EntityState.Deleted;
                    db.SaveChanges();
                    response.SetError(Common.SystemConstant.SystemConstants.ERRORS.SUCCESSFUL);
                }
                catch (Exception ex)
                {
                    response.SetError(Common.SystemConstant.SystemConstants.ERRORS.SYSTEMERROR);
                }
                return(response);
            }
        }
Esempio n. 10
0
 public void Update(Worker worker)
 {
     db.Entry(worker).State = EntityState.Modified;
 }