public ActionResult CreateEdit(PartViewModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (PartDataAccess.Update(model))
             {
                 return(Json(new { success = true, message = "Success" }, JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(new { success = false, message = PartDataAccess.Message }, JsonRequestBehavior.AllowGet));
             }
         }
         else
         {
             return(Json(new { success = false, message = "Lengkapi!" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Пример #2
0
 private async Task SetUpProperties()
 {
     PartModels       = (await PartDataAccess.GetAllParts()).ToList();
     UoMModels        = (await UoMDataAccess.GetAllUoMs()).ToList();
     DepartmentModels = (await DepartmentDataAccess.GetAllDepartments()).ToList();
     AlloyModels      = (await MaterialAlloyDataAccess.GetAllMaterialAlloys()).ToList();
     SeriesModels     = (await MaterialSeriesDataAccess.GetAllMaterialSeries()).ToList();
 }
 public ActionResult DeleteConfirm(int id)
 {
     if (PartDataAccess.Delete(id))
     {
         return(Json(new { success = true, message = "Success" }, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json(new { success = false, message = "Success" }, JsonRequestBehavior.AllowGet));
     }
     return(Json(new { success = false, message = "Error" }, JsonRequestBehavior.AllowGet));
 }
Пример #4
0
        public async Task <ActionResult> OnPost()
        {
            if (!ModelState.IsValid)
            {
                Message = new PopUpMessageModel()
                {
                    IsMessageGood = false,
                    Text          = "Could not create part"
                };
                await SetUpProperties();

                return(Page());
            }

            var partToSave = new PartModel()
            {
                PartName          = PartName,
                ExternalRev       = ExternalRev,
                Description       = Description,
                Dimensions        = Dimensions,
                RackId            = RackId,
                SurfaceArea       = SurfaceArea,
                SurfaceAreaUoMId  = SurfaceAreaUoM,
                PieceWeight       = PieceWeight,
                StandardDeptId    = StandardDept,
                Bake              = Bake,
                BasePrice         = BasePrice,
                MinLotCharge      = MinLotCharge,
                PartsPerLoad      = PartsPerLoad,
                MaskPcsPerHour    = MasksPcsPerHour,
                NotifyWhenMasking = NotifyWhenMasking,
                MaterialAlloyId   = MaterialAlloyId,
                MaterialSeriesId  = MaterialSeriesId,
                CreatedByEmpId    = 941
            };

            var resultingPart = await PartDataAccess.CreatePart(partToSave);

            Message = new PopUpMessageModel()
            {
                IsMessageGood = true,
                Text          = "Part saved successfully. Part ID: " + resultingPart.PartId
            };

            await SetUpProperties();

            return(Page());
        }
 public ActionResult Delete(int id)
 {
     return(View(PartDataAccess.GetById(id)));
 }
        public ActionResult List()
        {
            List <PartViewModel> model = PartDataAccess.GetAll();

            return(View(model));
        }