예제 #1
0
        public async Task <ActionResult> Create([Bind(Include = "MeshId,Name,CustValue,Yeild,Sublimation,MeasureId,ColorMeshId,DataCreate")] Mesh mesh)
        {
            if (ModelState.IsValid)
            {
                try{
                    db.Meshes.Add(mesh);
                    await db.SaveChangesAsync();
                }
                catch (System.Exception ex)
                {
                    if (ex.InnerException != null &&
                        ex.InnerException.InnerException != null &&
                        ex.InnerException.InnerException.Message.Contains("Mesh_Name_Index"))
                    {
                        ModelState.AddModelError(string.Empty, "Não é possível inserir com o mesmo nome!");
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, ex.Message);
                    }

                    ViewBag.MeasureId   = new SelectList(CombosHelper.GetMeasures(), "MeasureId", "Name", mesh.MeasureId);
                    ViewBag.ColorMeshId = new SelectList(CombosHelper.GetColors(), "ColorMeshId", "Color", mesh.ColorMeshId);
                    return(View(mesh));
                }
            }

            ViewBag.ColorMeshId = new SelectList(CombosHelper.GetColors(), "ColorMeshId", "Color", mesh.ColorMeshId);
            ViewBag.MeasureId   = new SelectList(CombosHelper.GetMeasures(), "MeasureId", "Name", mesh.MeasureId);
            return(View(mesh));
        }
        public async Task <ActionResult> Create([Bind(Include = "PrintSizeId,Name,SizeX,SizeY,ValueSize,MeasureId,DataCreate")] PrintSize printSize)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db.PrintSizes.Add(printSize);
                    await db.SaveChangesAsync();
                }

                catch (System.Exception ex)
                {
                    if (ex.InnerException != null &&
                        ex.InnerException.InnerException != null &&
                        ex.InnerException.InnerException.Message.Contains("PrintSize_Name_Index"))
                    {
                        ModelState.AddModelError(string.Empty, "Não é possível inserir com o mesmo nome!");
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, ex.Message);
                    }

                    ViewBag.MeasureId = new SelectList(CombosHelper.GetMeasures(), "MeasureId", "Name", printSize.MeasureId);

                    return(View(printSize));
                }

                return(RedirectToAction("Index"));
            }

            return(View(printSize));
        }
예제 #3
0
        // GET: Meshes/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Mesh mesh = await db.Meshes.FindAsync(id);

            if (mesh == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ColorMeshId = new SelectList(CombosHelper.GetColors(), "ColorMeshId", "Color", mesh.ColorMeshId);
            ViewBag.MeasureId   = new SelectList(CombosHelper.GetMeasures(), "MeasureId", "Name", mesh.MeasureId);
            return(View(mesh));
        }
예제 #4
0
 // GET: Meshes/Create
 public ActionResult Create()
 {
     ViewBag.ColorMeshId = new SelectList(CombosHelper.GetColors(), "ColorMeshId", "Color");
     ViewBag.MeasureId   = new SelectList(CombosHelper.GetMeasures(), "MeasureId", "Name");
     return(View());
 }