public IHttpActionResult PutAccesory(int id, Accesory accesory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != accesory.Tid) { return(BadRequest()); } db.Entry(accesory).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AccesoryExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void remove(Equip equip) { //Aquí se pone el equipo actual en el inventario. //Y le quito los buffs del objeto. inventoryManager.nounsInInventory.Add(equip); removeBuffs(equip); inventoryManager.DisplayInventory(); if (equip.GetType() == typeof(Tool)) { tool = null; } if (equip.GetType() == typeof(Outfit)) { outfit = null; } if (equip.GetType() == typeof(Bag)) { bag = null; } if (equip.GetType() == typeof(Accesory)) { accesory = null; } }
public ActionResult DeleteConfirmed(int id) { Accesory accesory = db.Accesories.Find(id); db.Accesories.Remove(accesory); db.SaveChanges(); return(RedirectToAction("Index")); }
public IHttpActionResult GetAccesory(int id) { Accesory accesory = db.Accesories.Find(id); if (accesory == null) { return(NotFound()); } return(Ok(accesory)); }
internal static AccesoryDto ToDto(Accesory accesoryEntity) { AccesoryDto dto = new AccesoryDto() { Brand = accesoryEntity.Brand, Description = accesoryEntity.Description, PartNumber = accesoryEntity.PartNumber }; return(dto); }
public IHttpActionResult PostAccesory(Accesory accesory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Accesories.Add(accesory); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = accesory.Tid }, accesory)); }
public ActionResult Edit([Bind(Include = "AccesoriesID,Name,PhotoID,OccasionID")] Accesory accesory) { if (ModelState.IsValid) { db.Entry(accesory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OccasionID = new SelectList(db.Occasions, "OccasionID", "Occasion1", accesory.OccasionID); ViewBag.PhotoID = new SelectList(db.Photos, "PhotoID", "Photo1", accesory.PhotoID); return(View(accesory)); }
public IHttpActionResult DeleteAccesory(int id) { Accesory accesory = db.Accesories.Find(id); if (accesory == null) { return(NotFound()); } db.Accesories.Remove(accesory); db.SaveChanges(); return(Ok(accesory)); }
// GET: Accesories/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Accesory accesory = db.Accesories.Find(id); if (accesory == null) { return(HttpNotFound()); } return(View(accesory)); }
//public ActionResult ModleDropDown(int CatId , int SubCatId , int ManfacId) //{ // TempData["MdDrop"] = DropDownHandler.Model(CatId, SubCatId, ManfacId); // return View(); //} public ActionResult AccesorySave(Accesory acc) { //var data = db.Accesories.Where(m => m.CatID == acc.CatID & m.SubCatID == acc.SubCatID & m.ModelID == acc.ModelID ).FirstOrDefault(); //if(data != null) //{ // return Content("errorr"); //} //else //{ db.Accesories.Add(acc); db.SaveChanges(); return(Content("save")); // } }
// GET: Accesories/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Accesory accesory = db.Accesories.Find(id); if (accesory == null) { return(HttpNotFound()); } ViewBag.OccasionID = new SelectList(db.Occasions, "OccasionID", "Occasion1", accesory.OccasionID); ViewBag.PhotoID = new SelectList(db.Photos, "PhotoID", "Photo1", accesory.PhotoID); return(View(accesory)); }
public void RegisterAccesory(Accesory accessory) { string query1 = "insert into Online_Store.dbo.tblAccessories values( '" + accessory.AccessoryName + "' , '" + accessory.AccessoryDetail + "')"; using (var db = new SqlConnection(connectionString)) { var SentenciaAEjecutar = new SqlCommand(query1, db); // abrimos connection db.Open(); var ex = SentenciaAEjecutar.ExecuteNonQuery(); db.Close(); } }
public void put(Equip equip) { if (equip.GetType() == typeof(Tool)) { if (tool != null) { remove(tool); } tool = equip as Tool; applyBuffs(tool); } if (equip.GetType() == typeof(Outfit)) { if (outfit != null) { remove(outfit); } outfit = equip as Outfit; applyBuffs(outfit); } if (equip.GetType() == typeof(Bag)) { if (bag != null) { remove(bag); } bag = equip as Bag; applyBuffs(bag); } if (equip.GetType() == typeof(Accesory)) { if (accesory != null) { remove(accesory); } accesory = equip as Accesory; applyBuffs(accesory); } //Le doy los buffs del objeto. inventoryManager.DisplayInventory(); updateText(); }
public async Task CreateAccesory(Accesory obj) { await _webApi.Create(obj); }
public async Task UpdateAccesory(int key, Accesory obj) { await _webApi.Update(key, obj); }
public async Task <IHttpActionResult> UploadImage() { if (HttpContext.Current.Request.Files.AllKeys.Any()) { string subjectId = HttpContext.Current.Request.Form[0]; string jsonSubject = HttpContext.Current.Request.Form[1]; string jsonAdvert = HttpContext.Current.Request.Form[2]; string jsonProduct = HttpContext.Current.Request.Form[3]; string Id = JsonConvert.DeserializeObject <string>(subjectId); var category = _db.dicCategories.Where(x => x.Id == Id).FirstOrDefault(); DomainModel.Advert advert = new DomainModel.Advert(); advert = JsonConvert.DeserializeObject <DomainModel.Advert>(jsonAdvert); advert.AdditionDate = DateTime.Now; dynamic subject = null; try { switch (category.CategoryId) { case 1: subject = new Boat(); SailBoat sailboat = new SailBoat(); var boat = JsonConvert.DeserializeObject <Boat>(jsonSubject); subject = JsonConvert.DeserializeObject <Boat>(jsonProduct); subject.AdvertDescription = boat.AdvertDescription; subject.AdvertName = boat.AdvertName; subject.Price = boat.Price; subject.Advert = advert; sailboat = JsonConvert.DeserializeObject <SailBoat>(jsonProduct); subject.SailBoat = sailboat; subject.CategoryId = category.CategoryId; _db.boats.Add(subject); break; case 2: subject = new Boat(); MotorBoat motorBoat = new MotorBoat(); var mBoat = JsonConvert.DeserializeObject <Boat>(jsonSubject); subject = JsonConvert.DeserializeObject <Boat>(jsonProduct); subject.AdvertDescription = mBoat.AdvertDescription; subject.AdvertName = mBoat.AdvertName; subject.Price = mBoat.Price; subject.Advert = advert; motorBoat = JsonConvert.DeserializeObject <MotorBoat>(jsonProduct); subject.MotorBoat = motorBoat; subject.CategoryId = category.CategoryId; break; case 3: subject = new DomainModel.Engine(); ApiContract.Subject enginePar = JsonConvert.DeserializeObject <ApiContract.Subject>(jsonSubject); ApiContract.Engine subjectApiContract = JsonConvert.DeserializeObject <ApiContract.Engine>(jsonProduct); _mapper.Map <ApiContract.Subject, DomainModel.Engine>(enginePar, subject); _mapper.Map <ApiContract.Engine, DomainModel.Engine>(subjectApiContract, subject); //subject.Price = subjectJsonPar.Price; //subject.BuiltYear = subjectJsonPar.BuiltYear; //subject.Brand = subjectJsonPar.Brand; //subject.Power = subjectJsonPar.Power; //subject.TypeOfEngine = subjectJsonPar.TypeOfEngine; //subject.TypeOfFuel = subjectJsonPar.TypeOfFuel; //subject = enginePar; //subject.Brand = enginePar.Brand; subject.CategoryId = category.CategoryId; subject.Advert = advert; break; case 4: subject = new Trailor(); var trailorParams = JsonConvert.DeserializeObject <Trailor>(jsonSubject); subject = JsonConvert.DeserializeObject <Trailor>(jsonProduct); subject.CategoryId = category.CategoryId; subject.Advert = advert; break; case 5: subject = new Sail(); var sailParams = JsonConvert.DeserializeObject <Sail>(jsonSubject); subject = JsonConvert.DeserializeObject <Sail>(jsonProduct); subject.CategoryId = category.CategoryId; subject.Advert = advert; break; case 6: subject = new Accesory(); var accessoryParams = JsonConvert.DeserializeObject <Accesory>(jsonSubject); subject = JsonConvert.DeserializeObject <Accesory>(jsonProduct); subject.CategoryId = category.CategoryId; subject.Advert = advert; break; } } catch (Exception ex) { return(BadRequest(ex.Message)); } try { foreach (string fileName in HttpContext.Current.Request.Files) { var httpPostedFile = HttpContext.Current.Request.Files[fileName]; if (httpPostedFile != null) { DomainModel.Image uploadedImg = new DomainModel.Image(); int length = httpPostedFile.ContentLength; uploadedImg.ImageData = new byte[length]; httpPostedFile.InputStream.Read(uploadedImg.ImageData, 0, length); uploadedImg.Name = Path.GetFileName(httpPostedFile.FileName); uploadedImg.Identifier = Guid.NewGuid(); uploadedImg.Subject = subject; _db.images.Add(uploadedImg); var fileSavePath = Path.Combine(HttpContext.Current.Server.MapPath("~/AdvertImages"), httpPostedFile.FileName); httpPostedFile.SaveAs(fileSavePath); } } _db.SaveChanges(); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } } return(Ok()); }