public ActionResult Edit(FlowerView view) { if (ModelState.IsValid) { var pic = view.Image; //la inicializo en la imagen vieja por si el no la cambio no la daƱe var folder = "~/Content/Images"; if (view.ImageFile != null) { pic = FilesHelper.UploadPhoto(view.ImageFile, folder); pic = string.Format("{0}/{1}", folder, pic); } var flower = ToFlower(view); //convertimos a vista flower.Image = pic; db.Entry(flower).State = EntityState.Modified; try { db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { ex.ToString(); } } return(View(view)); }
public void PositionFlower(FlowerView flowerView) { Vector3 position = new Vector3(); position.x = axisX.Value; position.y = axisY.Value; position.z = axisZ.Value; flowerView.transform.position = position; }
private Flower ToFlower(FlowerView view) { return(new Models.Flower { Description = view.Description, FlowerId = view.FlowerId, Image = view.Image, IsActive = view.IsActive, LastPurchase = view.LastPurchase, Observation = view.Observation, Price = view.Price, }); }
public Flower GetFlower() { Flower flower = new Flower(); FlowerView view = GetFlowerPrefab().AddComponent <FlowerView>(); view.FlowerModel = flower; flower.FlowerView = view; flower.Honey = settings.StartHoney.Value; flower.HoneyRegeneration = settings.HoneyRegeneration.Value; flower.MaxBees = settings.MaxBeesOnFlower; positioner.PositionFlower(view); return(flower); }
public ActionResult Edit( //[Bind(Include = "FlowerId,Description,Price,LastPurchase,Image,IsActive,Observation")] FlowerView view) { if (ModelState.IsValid) { var pic = view.Image; var folder = "~/Content/Images"; if (view.ImageFile != null) { pic = FilesHelper.UploadPhoto(view.ImageFile, folder); pic = string.Format("{0}/{1}", folder, pic); } var flower = ToFlower(view); flower.Image = pic; db.Entry(flower).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(view)); }
//public ActionResult Create([Bind(Include = "FlowerId,Description,Price,LastPurchase,Image,IsActive,Observation")] Flower flower) public ActionResult Create(FlowerView view) { if (ModelState.IsValid) { var pic = string.Empty; var folder = "~/Content/Images"; if (view.ImageFile != null) { pic = FilesHelper.UploadPhoto(view.ImageFile, folder); pic = string.Format("{0}/{1}", folder, pic); } var flower = ToFlower(view); flower.Image = pic; //db.Flowers.Add(flower); db.Flowers.Add(flower); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(view)); // return View(flower); }
public ActionResult FlowerDetails(FlowerView flowerview) { return(View(flowerview)); }