// DELETE: api/Testimonial/5
        public IHttpActionResult Delete(int id)
        {
            var result = new Result <String>();

            using (var db = new jupiterEntities())
            {
                Testimonial testimonial = db.Testimonials.Find(id);
                if (testimonial == null)
                {
                    return(Json(DataNotFound(result)));
                }
                try
                {
                    db.Testimonials.Remove(testimonial);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    result.ErrorMessage = e.Message;
                    result.IsSuccess    = false;
                    return(Json(result));
                }
            }
            return(Json(result));
        }
Esempio n. 2
0
        public IHttpActionResult PutProject(int id, ProjectModel projectModel)
        {
            var result = new Result <string>();

            using (var db = new jupiterEntities())
            {
                var a = db.Projects.Where(x => x.ProjectId == id).Select(x => x).FirstOrDefault();
                if (a == null)
                {
                    return(Json(DataNotFound(result)));
                }

                Type type = typeof(Project);
                UpdateTable(projectModel, type, a);

                try
                {
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    result.ErrorMessage = e.Message;
                    result.IsSuccess    = false;
                    return(Json(result));
                }
            }
            return(Json(result));
        }
Esempio n. 3
0
        public IHttpActionResult Delete(int id)
        {
            var result = new Result <String>();

            using (var db = new jupiterEntities())
            {
                var a = db.CartProds.Where(x => x.Id == id).Select(x => x).FirstOrDefault();
                if (a == null)
                {
                    return(Json(DataNotFound(result)));
                }

                try
                {
                    db.CartProds.Remove(a);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    result.ErrorMessage = e.Message;
                    result.IsSuccess    = false;
                    return(Json(result));
                }
                return(Json(result));
            }
        }
Esempio n. 4
0
        public IHttpActionResult Put(int id, [FromBody] CartProdModel cartProdModel)
        {
            var  result = new Result <String>();
            Type type   = typeof(CartProd);

            using (var db = new jupiterEntities())
            {
                var a = db.CartProds.Where(x => x.Id == id).Select(x => x).FirstOrDefault();
                if (a == null)
                {
                    return(Json(DataNotFound(result)));
                }
                UpdateTable(cartProdModel, type, a);
                try
                {
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    result.IsSuccess    = false;
                    result.ErrorMessage = e.Message;
                    return(Json(result));
                }
                return(Json(result));
            }
        }
Esempio n. 5
0
        // DELETE: api/Project/5
        public IHttpActionResult DeleteProject(int id)
        {
            var result = new Result <string>();

            using (var db = new jupiterEntities())
            {
                Project project = db.Projects.Find(id);
                if (project == null)
                {
                    return(Json(DataNotFound(result)));
                }

                try
                {
                    db.Projects.Remove(project);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    result.ErrorMessage = e.Message;
                    result.IsSuccess    = false;
                    return(Json(result));
                }
            }
            return(Json(result));
        }
Esempio n. 6
0
        public IHttpActionResult Put(int id, [FromBody] ProductCategoryModel upCategory)
        {
            var result = new Result <string>();

            using (var dbContext = new jupiterEntities())
            {
                ProductCategory updatedCate = dbContext.ProductCategories.Where(x => x.CategroyId == id).Select(x => x).FirstOrDefault();
                if (updatedCate == null)
                {
                    return(Json(DataNotFound(result)));
                }
                Type type = typeof(ProductCategory);
                UpdateTable(upCategory, type, updatedCate);
                try
                {
                    dbContext.SaveChanges();
                }
                catch (Exception e)
                {
                    result.IsSuccess    = false;
                    result.ErrorMessage = e.Message;
                }
                return(Json(result));
            }
        }
Esempio n. 7
0
        public IHttpActionResult Put(int id, [FromBody] ContactModel contactModel)
        {
            var  result  = new Result <string>();
            Type conType = typeof(Contact);

            using (var db = new jupiterEntities())
            {
                Contact a = db.Contacts.Where(x => x.ContactId == id).Select(x => x).FirstOrDefault();
                if (a == null)
                {
                    result.ErrorMessage = "Not Found";
                    result.IsFound      = false;
                    return(Json(result));
                }
                UpdateTable(contactModel, conType, a);
                try
                {
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    result.ErrorMessage = e.Message;
                    result.IsSuccess    = false;
                    return(Json(result));
                }
                return(Json(result));
            }
        }
Esempio n. 8
0
        public IHttpActionResult Delete(int id)
        {
            var result = new  Result <string>();

            using (var db = new jupiterEntities())
            {
                var a = db.Products.Find(id);
                if (a == null)
                {
                    return(Json(DataNotFound(result)));
                }

                try
                {
                    a.IsActivate = 0;
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    result.ErrorMessage = e.Message;
                    result.IsSuccess    = false;
                }

                return(Json(result));
            }
        }
Esempio n. 9
0
        public IHttpActionResult Post([FromBody] ProductModel productModel)
        {
            var result = new Result <string>();

            using (var db = new jupiterEntities())
            {
                Product product = new Product();
                productModel.CreateOn = DateTime.Now;
                Mapper.Map(productModel, product);
                try
                {
                    db.Products.Add(product);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    result.IsSuccess    = false;
                    result.ErrorMessage = e.Message;
                }
                try
                {
                    if (productModel.ProdMedias.Count != 0)
                    {
                        foreach (var pm in productModel.ProdMedias)
                        {
                            ProductMedia prodMedia = new ProductMedia();
                            prodMedia.ProdId = product.ProdId;
                            {
                                prodMedia.Url = pm;
                            };
                            db.ProductMedias.Add(prodMedia);
                        }
                        db.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    result.IsSuccess    = false;
                    result.ErrorMessage = e.Message;
                }
                return(Json(result));
            }
        }
Esempio n. 10
0
        public IHttpActionResult Put(int id, [FromBody] ProductMediaModel productMediaModel)
        {
            var result = new Result <string>();
            var a      = db.ProductMedias.Where(x => x.Id == id).Select(x => x).FirstOrDefault();

            if (a == null)
            {
                return(Json(DataNotFound(result)));
            }
            Type type = typeof(ProductMedia);

            UpdateTable(productMediaModel, type, a);
            try
            {
                db.SaveChanges();
            }
            catch (Exception e)
            {
                result.ErrorMessage = e.Message;
                result.IsSuccess    = false;
                return(Json(result));
            }
            return(Json(result));
        }
Esempio n. 11
0
        public IHttpActionResult Post([FromBody] CartProdModel cartProdModel)
        {
            var result = new Result <String>();

            using (var db = new jupiterEntities())
            {
                CartProd cartProd = new CartProd();
                Mapper.Map(cartProdModel, cartProd);
                try
                {
                    db.CartProds.Add(cartProd);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    result.ErrorMessage = e.Message;
                    result.IsSuccess    = false;
                    return(Json(result));
                }
                return(Json(result));
            }
        }
Esempio n. 12
0
        public IHttpActionResult Post([FromBody] ProductCategoryModel productCategory)
        {
            var result = new Result <string>();

            using (var db = new jupiterEntities())
            {
                ProductCategory proCategory = new ProductCategory();

                Mapper.Map(productCategory, proCategory);
                try
                {
                    db.ProductCategories.Add(proCategory);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    result.IsSuccess    = false;
                    result.ErrorMessage = e.Message;
                }
                return(Json(result));
            }
        }
Esempio n. 13
0
        public IHttpActionResult PostProject(ProjectModel projectModel)
        {
            var result = new Result <string>();

            using (var db = new jupiterEntities())
            {
                Project project = new Project();
                Mapper.Map(projectModel, project);
                db.Projects.Add(project);
                try
                {
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    result.ErrorMessage = e.Message;
                    result.IsSuccess    = false;
                    return(Json(result));
                }
                return(Json(result));
            }
        }
Esempio n. 14
0
        public IHttpActionResult Post([FromBody] CartModel newCart)
        {
            var result = new Result <string>();

            using (var db = new jupiterEntities())
            {
                Cart newDb = new Cart();

                Mapper.Map(newCart, newDb);
                try
                {
                    db.Carts.Add(newDb);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    result.ErrorMessage = e.Message;
                    result.IsSuccess    = false;
                }
                return(Json(result));
            }
        }
Esempio n. 15
0
        public IHttpActionResult Post(EventTypeModel eventTypeModel)
        {
            var       result    = new Result <string>();
            EventType eventType = new EventType();

            Mapper.Map(eventTypeModel, eventType);
            using (var db = new jupiterEntities())
            {
                try
                {
                    db.EventTypes.Add(eventType);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    result.ErrorMessage = e.Message;
                    result.IsSuccess    = false;
                    return(Json(result));
                }
            }
            return(Json(result));
        }
Esempio n. 16
0
        public IHttpActionResult Post([FromBody] ContactModel contactModel)
        {
            var result = new Result <string>();

            using (var db = new jupiterEntities())
            {
                Contact a = new Contact();
                Mapper.Map(contactModel, a);
                try
                {
                    db.Contacts.Add(a);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    result.ErrorMessage = e.Message;
                    result.IsSuccess    = false;
                    return(Json(result));
                }

                return(Json(result));
            }
        }
        public IHttpActionResult Post([FromBody] TestimonialModel testimonialModel)
        {
            var         result      = new Result <TestimonialModel>();
            Testimonial testimonial = new Testimonial();

            using (var db = new jupiterEntities())
            {
                Mapper.Map(testimonialModel, testimonial);
                result.Data = testimonialModel;
                try
                {
                    db.Testimonials.Add(testimonial);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    result.ErrorMessage = e.Message;
                    result.IsSuccess    = false;
                    return(Json(result));
                }
            }
            return(Json(result));
        }
Esempio n. 18
0
        public IHttpActionResult Delete(int id)
        {
            var result = new Result <string>();

            using (var db = new jupiterEntities())
            {
                ProductCategory del = db.ProductCategories.FirstOrDefault(x => x.CategroyId == id);
                if (del == null)
                {
                    return(Json(DataNotFound(result)));
                }
                try
                {
                    db.ProductCategories.Remove(del);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    result.ErrorMessage = e.Message;
                    result.IsSuccess    = false;
                }
                return(Json(result));
            }
        }