Ejemplo n.º 1
0
        public async Task <ActionResult <User> > Update(User model, long id)
        {
            var firstName = model.FirstName;
            var lastName  = model.LastName;
            var userName  = model.UserName;
            var password  = model.Password;
            var role      = model.Role;
            var token     = model.Token;

            var users = _context.User.FirstOrDefault(m => m.Id == id);

            if (model != null)
            {
                users.FirstName = model.FirstName;
                users.LastName  = model.LastName;
                users.Role      = model.Role;
                users.UserName  = model.UserName;

                _context.Update(users);
                //   _context.Entry(User).State = EntityState.Modified;

                await _context.SaveChangesAsync();

                return(Ok());
            }
            return(BadRequest());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PutCategories(long id, Categories model)
        {
            var categoryId = model.CategoryName;
            var categories = _context.Categories.FirstOrDefault(m => m.Id == id);

            if (model != null)
            {
                categories.CategoryName = model.CategoryName;

                _context.Update(categories);
                await _context.SaveChangesAsync();

                return(Ok());
            }
            return(BadRequest());
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <BusinessListing> > PutTodoItem(long id, BusinessListing model)
        {
            //   var id = model.Id;

            var customerName        = model.CustomerName;
            var emailAddress        = model.Email;
            var businessName        = model.BusinessName;
            var businessAddress     = model.Address;
            var city                = model.City;
            var lga                 = model.Lga;
            var url                 = model.Url;
            var businessDescription = model.Description;
            var categoryId          = model.CategoryId;

            var categories      = _context.Categories.Where(m => m.Id == categoryId);
            var businesslisting = _context.BusinessListing.FirstOrDefault(m => m.Id == id);

            if (model != null)
            {
                businesslisting.CustomerName = model.CustomerName;
                businesslisting.Email        = model.Email;
                businesslisting.BusinessName = model.BusinessName;
                businesslisting.Address      = model.Address;
                businesslisting.City         = model.City;
                businesslisting.Lga          = model.Lga;
                businesslisting.Url          = model.Url;
                businesslisting.Description  = model.Description;
                _context.Update(businesslisting);
                await _context.SaveChangesAsync();
            }



            /* if (id != model.Id)
             * {
             *   return BadRequest();
             * }*/

            // _context.Entry(model).State = EntityState.Modified;


            return(Ok());
        }