public ActionResult Create(Project model, HttpPostedFileBase files)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.GuitarBody = this.GuitarService.GetAllGuitarBodys();
                ViewBag.GuitarNeck = this.GuitarService.GetAllGuitarNecks();
                ViewBag.GuitarBridge = this.GuitarService.GetAllGuitarBridges();
                ViewBag.GuitarPickup = this.GuitarService.GetAllGuitarPickups();
                return View(model);
            }

            if (files != null)
            {

                var fileName = string.Format("/Images/{0}",
                    "Guitar_" + string.Format("{0:HHmmssfff}", DateTime.Now) + Path.GetExtension(files.FileName));
                files.SaveAs(this.Server.MapPath(fileName));
                model.ImgProject = fileName;
            }

            this.GuitarService.Create(model);
            return RedirectToAction("Index");
        }
 public void Delete(Project Model)
 {
     var context = new GuitarDbContext();
     context.Entry(Model).State = System.Data.Entity.EntityState.Deleted;
     context.SaveChanges();
 }
 public void Create(Project Model)
 {
     var context = new GuitarDbContext();
     context.Project.Add(Model);
     context.SaveChanges();
 }
        public Project GetOne(int id)
        {
            IEnumerable<Project> result = new List<Project>();
            Project res = new Project();

            using (var con = new SqlConnection(this.ConnectionString))
            {
                con.Open();

                var p = new DynamicParameters();
                p.Add("@xId", id);
                result = con.Query<Project>("GetOne", p, commandType: System.Data.CommandType.StoredProcedure);
                con.Close();
            }

            //var context = new GuitarDbContext();

            //var query = (from p in context.Project
            //             join gb in context.GuitarBody on p.BodyID equals gb.Id
            //             where p.Id == id
            //             select new { name = p.Name, description = p.Description, body = gb.Description });

            res = result.FirstOrDefault();

            return res;
        }
예제 #5
0
 public void Update(Project Model)
 {
     this.GuitarRepositorio.Update(Model);
 }
예제 #6
0
 public void Delete(Project Model)
 {
     this.GuitarRepositorio.Delete(Model);
 }
예제 #7
0
 //--------------------------------------------------------
 public void Create(Project Model)
 {
     this.GuitarRepositorio.Create(Model);
 }
        public ActionResult Edit(Project model)
        {
            if (!ModelState.IsValid)
            {
                // fetch the guitar body(and extras) again to populate the dropdowns
                ViewBag.GuitarBody = this.GuitarService.GetAllGuitarBodys();
                ViewBag.GuitarNeck = this.GuitarService.GetAllGuitarNecks();
                ViewBag.GuitarBridge = this.GuitarService.GetAllGuitarBridges();
                ViewBag.GuitarPickup = this.GuitarService.GetAllGuitarPickups();
                return View(model);
            }

            this.GuitarService.Update(model);
            return RedirectToAction("Index");
        }