public async Task <IActionResult> PutMedico(string id, Medicos medico)
        {
            if (id != medico.Dni)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IHttpActionResult> PutInsurance(int id, Insurance insurance)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
        public async Task <bool> AddOrder(Order order)
        {
            _context.Orders.Add(order);
            await _context.SaveChangesAsync();

            return(await Task.FromResult <bool>(true));
        }
Ejemplo n.º 4
0
        public async Task <bool> AddProduct(AddProductDto productdto)
        {
            Product adedproduct = productdto.Adapt <Product>();
            await _context.Products.AddAsync(adedproduct);

            await _context.SaveChangesAsync();

            if (!await _categoryManager.AddProductCategoryRelation(productdto.CategoryId, adedproduct.ProductId))
            {
                throw new Exception("Product And Category Relation Requried");
            }

            if (!await _stockManager.SetStockPropertyCombination(productdto.CategoryId, adedproduct.ProductId))
            {
                throw new Exception("Product Variation Requried");
            }

            if (!await AddProductImages(productdto.Images, adedproduct.ProductId))
            {
                throw new Exception("Product Images Requried");
            }

            //ProductElasticIndexDto productElasticIndexDto = new ProductElasticIndexDto();
            //productElasticIndexDto.Adapt(adedproduct);
            //await CreateIndexes(productElasticIndexDto);
            return(await Task.FromResult <bool>(true));
        }
        public async Task <IActionResult> PutBProcessFlow([FromRoute] int id, [FromBody] BProcessFlow bProcessFlow)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Putusuarios(int id, usuarios usuarios)
        {
            if (id != usuarios.usuarioId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutSummaryTotal(int id, SummaryTotal summaryTotal)
        {
            if (id != summaryTotal.StID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 8
0
        public async Task <ActionResult <Movie> > PostMovie(Movie movie)
        {
            _context.movies.Add(movie);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMovie", new { id = movie.Id }, movie));
        }
        public async Task <IActionResult> PutEspecialidades(int id, Especialidades especialidades)
        {
            if (id != especialidades.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> PutParticipante(int id, Participante participante)
        {
            if (id != participante.ParticipanteID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 11
0
        public async Task <bool> AddProperty(Property property)
        {
            _context.Properties.Add(property);
            await _context.SaveChangesAsync();

            return(await Task.FromResult <bool>(true));
        }
Ejemplo n.º 12
0
        public async Task <ActionResult <User> > PostUser(User item)
        {
            _context.Users.Add(item);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", "User"));
        }
Ejemplo n.º 13
0
        public async Task <ActionResult <Usuario> > AddUsuario(Usuario usuario)
        {
            _context.Usuario.Add(usuario);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetUsuario), new { id = usuario.IdUsuario }, usuario));
        }
Ejemplo n.º 14
0
        public async Task <IActionResult> PutStorage(long id, [FromForm] Storage storage)
        {
            if (id != storage.IdProduct)
            {
                return(BadRequest());
            }

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

            try
            {
                return(Ok(new { status = await _context.SaveChangesAsync() != 0, data = "Cập nhật thành công" }));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StorageExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    return(Ok(new { status = false, data = "Cập nhật thất bại" }));
                }
            }
        }
Ejemplo n.º 15
0
        public async Task <ActionResult> Create([FromBody] judge judgeObject)
        {
            if (judgeObject.EmailAddress.Length == 0)
            {
                return(BadRequest(new { Message = "Judge record cannot be created. Email is missing." }));
            }
            else if (judgeObject.JudgeName.Length == 0)
            {
                return(BadRequest(new { Message = "Judge record cannot be created. Judge Name is missing." }));
            }
            else if (judgeObject.AICupperAccountID == null)
            {
                return(BadRequest(new { Message = "Judge record cannot be created. AICUPPER Account is missing." }));
            }
            else
            {
                try {
                    _context.Add(judgeObject);
                    await Task.Run(() => _context.SaveChangesAsync());

                    return(Accepted(new { Message = "Judge record successfully created" }));
                } catch (Exception ex) {
                    return(StatusCode(500));
                }
            }
        }
        public async Task <IActionResult> PutHorarios(List <Horarios> horarios)
        {
            foreach (Horarios item in horarios)
            {
                //if (id != item.Id)
                //{
                //    return BadRequest();
                //}
                _context.Entry(item).State = EntityState.Modified;
            }

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                //if (!HorariosExists(id))
                //{
                return(NotFound((new { Estado = false, Mensaje = "No se puede actualizar", error = ex.Message })));

                //}
                //else
                //{
                //    throw;
                //}
            }

            return(Ok((new { Estado = true, Mensaje = "Datos actualizados", error = "" })));
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> PutTime(int id, [FromBody] Time time)
        {
            if (id != time.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 18
0
        public async Task <News> InsertNews(News newsForInsert)
        {
            try
            {
                if (newsForInsert.UserCreated != null)
                {
                    News newNews = new News();
                    newNews.Text         = newsForInsert.Text;
                    newNews.Title        = newsForInsert.Title;
                    newNews.Status       = newsForInsert.Status;
                    newNews.DateInserted = newsForInsert.DateInserted;
                    newNews.UserCreated  = newsForInsert.UserCreated;
                    dbContext.News.Add(newNews);
                    await dbContext.SaveChangesAsync();

                    return(newNews);
                }
                else
                {
                    throw new Exception("User doesnt exist");
                }
            }
            catch (Exception ex)
            {
                // moze se dodati logger koji upisuje exceptione u neku bazu
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 19
0
        public async Task <IActionResult> PutOrderDetail(long id, OrderDetail orderDetail)
        {
            if (id != orderDetail.Idd)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutPWorkOrder([FromRoute] int id, [FromBody] PWorkOrder pWorkOrder)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
Ejemplo n.º 21
0
        public async Task <IActionResult> PutProduct(long id, [FromForm] Product product)
        {
            if (id != product.Id)
            {
                return(BadRequest());
            }

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

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

            return(Ok(new{ status = true }));
        }
        public async Task <IActionResult> PutProductDetail(long id, [FromForm] ProductDetail productDetail)
        {
            if (id != productDetail.IdProduct)
            {
                return(BadRequest());
            }

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

            try
            {
                return(Ok(new { status = await _context.SaveChangesAsync() != 0, data = "Thành công" }));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    return(Ok(new { status = false, data = "Có lỗi xảy ra" }));
                }
            }
        }
        public async Task <IActionResult> PutCountryView(int id, CountryView countryView)
        {
            if (id != countryView.CvID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 24
0
        public async Task <IActionResult> Put([FromRoute] int id, [FromBody] question question)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (id != question.qID)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!QuizExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(NotFound());
        }
Ejemplo n.º 25
0
        public async Task <ActionResult <Product> > PostProduct(Product item)
        {
            _context.Products.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetProducts), new { id = item.ProductId }, item));
        }
Ejemplo n.º 26
0
        public async Task <IActionResult> PutRole(long id, Role role)
        {
            if (id != role.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 27
0
        public async Task <IActionResult> PutUsers(int id, User User)
        {
            if (id != User.id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 28
0
        public async Task <IActionResult> PutBWorkToolPropertyDetail([FromRoute] int id, [FromBody] BWorkToolPropertyDetail bWorkToolPropertyDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
Ejemplo n.º 29
0
        public async Task <IActionResult> PutSModuleInRole([FromRoute] int id, [FromBody] SModuleInRole sModuleInRole)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
Ejemplo n.º 30
0
        public async Task <IActionResult> PutCatalog(long id, [FromForm] Catalog catalog, [FromQuery] string platform)
        {
            if (platform is null)
            {
                return(Ok(new { status = true, data = "Web API" }));
            }
            else
            {
                if (id != catalog.Id)
                {
                    return(BadRequest());
                }

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

                try
                {
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CatalogExists(id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(Ok(new { status = true, data = "Cập nhật thành công" }));
            }
        }