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)); }
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)); } }
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)); } }
// 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)); }
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)); } }
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)); } }
// 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)); }
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)); } }
// GET: api/EventType public IHttpActionResult Get() { var result = new Result <List <EventTypeModel> >(); List <EventTypeModel> eventTypeModels = new List <EventTypeModel>(); using (var db = new jupiterEntities()) { List <EventType> eventTypes = db.EventTypes.ToList(); Mapper.Map(eventTypes, eventTypeModels); result.Data = eventTypeModels; } return(Json(result)); }
// GET: ProductCategory public IHttpActionResult Get() { var result = new Result <List <ProductCategoryModel> >(); using (var db = new jupiterEntities()) { List <ProductCategoryModel> productCategoryModels = new List <ProductCategoryModel>(); List <ProductCategory> productCategories = db.ProductCategories.ToList(); Mapper.Map(productCategories, productCategoryModels); result.Data = productCategoryModels; return(Json(result)); } }
public IHttpActionResult GetByType(int type) { var result = new Result <List <ProductModel> >(); using (var db = new jupiterEntities()) { List <Product> products = db.Products.Where(x => x.ProdTypeId == type).Select(x => x).ToList(); List <ProductModel> productModels = new List <ProductModel>(); Mapper.Map(products, productModels); result.Data = productModels; return(Json(result)); } }
public IHttpActionResult Get() { var result = new Result <List <CartProdModel> >(); using (var db = new jupiterEntities()) { List <CartProdModel> cardProdModels = new List <CartProdModel>(); List <CartProd> cartProds = db.CartProds.ToList(); Mapper.Map(cartProds, cardProdModels); result.Data = cardProdModels; return(Json(result)); } }
// GET: api/Testimonial public IHttpActionResult Get() { var result = new Result <List <TestimonialModel> >(); List <TestimonialModel> testimonialModels = new List <TestimonialModel>(); using (var db = new jupiterEntities()) { List <Testimonial> testimonials = db.Testimonials.Select(x => x).ToList(); Mapper.Map(testimonials, testimonialModels); result.Data = testimonialModels; } return(Json(result)); }
public IHttpActionResult Get() { var result = new Result <List <ContactModel> >(); using (var db = new jupiterEntities()) { List <ContactModel> contactModels = new List <ContactModel>(); List <Contact> contacts = db.Contacts.ToList(); Mapper.Map(contacts, contactModels); result.Data = contactModels; return(Json(result)); } }
public IHttpActionResult Get(int id) { var result = new Result <CartProdModel>(); CartProdModel cartProdModel = new CartProdModel(); 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))); } Mapper.Map(a, cartProdModel); result.Data = cartProdModel; return(Json(result)); } }
// GET: api/Product/5 public IHttpActionResult Get(int id) { var result = new Result <ProductModel>(); using (var db = new jupiterEntities()) { Product product = db.Products.Find(id); ProductModel productModel = new ProductModel(); if (product == null) { return(Json(DataNotFound(result))); } Mapper.Map(product, productModel); result.Data = productModel; return(Json(result)); } }
public IHttpActionResult Get(int id) { var result = new Result <ProductCategoryModel>(); using (var db = new jupiterEntities()) { var a = db.ProductCategories.Where(x => x.CategroyId == id).Select(x => x).FirstOrDefault(); if (a == null) { return(Json(DataNotFound(result))); } ProductCategoryModel productCategoryModel = new ProductCategoryModel(); Mapper.Map(a, productCategoryModel); result.Data = productCategoryModel; return(Json(result)); } }
// GET: api/EventType/5 public IHttpActionResult Get(int id) { var result = new Result <EventTypeModel>(); using (var db = new jupiterEntities()) { EventType eventType = db.EventTypes.Find(id); EventTypeModel eventTypeModel = new EventTypeModel(); if (eventType == null) { return(Json(DataNotFound(result))); } Mapper.Map(eventType, eventTypeModel); result.Data = eventTypeModel; } return(Json(result)); }
// GET: api/Testimonial/5 public IHttpActionResult Get(int id) { var result = new Result <TestimonialModel>(); using (var db = new jupiterEntities()) { Testimonial testimonial = db.Testimonials.Find(id); TestimonialModel testimonialModel = new TestimonialModel(); if (testimonial == null) { return(Json(DataNotFound(result))); } Mapper.Map(testimonial, testimonialModel); result.Data = testimonialModel; } return(Json(result)); }
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)); } }
public IHttpActionResult Get(int id) { var result = new Result <ContactModel>(); using (var db = new jupiterEntities()) { var a = db.Contacts.Where(x => x.ContactId == id).Select(x => x).FirstOrDefault(); if (a == null) { result.IsFound = false; result.ErrorMessage = "Not Found"; return(Json(result)); } ContactModel contactModel = new ContactModel(); Mapper.Map(a, contactModel); result.Data = contactModel; return(Json(result)); } }
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)); }
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)); } }
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)); } }
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)); } }
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)); } }
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)); }
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)); } }