public async Task <IActionResult> Edit(int id, [Bind("ProductQualityId,ProductQualityName,OwnerSignature,EntryDate")] ProductQuality productQuality)
        {
            if (id != productQuality.ProductQualityId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(productQuality);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductQualityExists(productQuality.ProductQualityId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(productQuality));
        }
        public IActionResult Update([FromBody] ProductQuality productQuality)
        {
            try
            {
                var res = _dbContext.ProductQualities.FirstOrDefault(a => a.ID == productQuality.ID);

                if (res != null)
                {
                    res.DefectDetails  = productQuality.DefectDetails;
                    res.Factory        = productQuality.Factory;
                    res.FiringOrRework = productQuality.FiringOrRework;
                    res.Quality        = productQuality.Quality;
                    res.Size           = productQuality.Size;
                    res.TypeOfFormer   = productQuality.TypeOfFormer;
                    res.Shift          = productQuality.Shift;

                    _dbContext.ProductQualities.Update(res);
                    _dbContext.SaveChanges();
                }

                return(Ok(res));
            }
            catch (Exception ex)
            {
                return(BadRequest("Something went wrong, item not updated" + ex.Message));
            }
        }
Beispiel #3
0
 public bool HighQuality()
 {
     if (ProductQuality.Equals(_quality[0]) || ProductQuality.Equals(_quality[1]))
     {
         return(true);
     }
     return(false);
 }
Beispiel #4
0
        // GET: /ProductMaster/Create

        public ActionResult Create(int id)//ProductType Id
        {
            ProductQuality vm = new ProductQuality();

            vm.IsActive      = true;
            vm.ProductTypeId = id;
            ViewBag.id       = id;
            ViewBag.Name     = new ProductTypeService(_unitOfWork).Find(vm.ProductTypeId).ProductTypeName;
            return(View("Create", vm));
        }
        public async Task <IActionResult> Create([Bind("ProductQualityId,ProductQualityName,OwnerSignature,EntryDate")] ProductQuality productQuality)
        {
            if (ModelState.IsValid)
            {
                _context.Add(productQuality);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(productQuality));
        }
Beispiel #6
0
        // GET: /ProductMaster/Edit/5

        public ActionResult Edit(int id)
        {
            ProductQuality pt = _ProductQualityService.Find(id);

            if (pt == null)
            {
                return(HttpNotFound());
            }
            ViewBag.id   = pt.ProductTypeId;
            ViewBag.Name = new ProductTypeService(_unitOfWork).Find(pt.ProductTypeId).ProductTypeName;
            return(View("Create", pt));
        }
        public IActionResult AddQualityDetail([FromBody] ProductQuality product)
        {
            product.ID = Guid.NewGuid();
            product.CreatedDateTime  = product.CreatedDateTime.Date;
            product.UploadedDateTime = DateTime.UtcNow;

            try
            {
                _dbContext.ProductQualities.Add(product);
                _dbContext.SaveChanges();
                return(Ok(product));
            }
            catch
            {
                return(BadRequest("Something went wrong, Details not added"));
            }
        }
Beispiel #8
0
        // GET: /ProductMaster/Delete/5

        public ActionResult Delete(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductQuality ProductQuality = _ProductQualityService.Find(id);

            if (ProductQuality == null)
            {
                return(HttpNotFound());
            }

            ReasonViewModel vm = new ReasonViewModel()
            {
                id = id,
            };

            return(PartialView("_Reason", vm));
        }
 public ProductQuality Add(ProductQuality pt)
 {
     _unitOfWork.Repository <ProductQuality>().Insert(pt);
     return(pt);
 }
 public void Update(ProductQuality pt)
 {
     pt.ObjectState = ObjectState.Modified;
     _unitOfWork.Repository <ProductQuality>().Update(pt);
 }
 public void Delete(ProductQuality pt)
 {
     _unitOfWork.Repository <ProductQuality>().Delete(pt);
 }
 public ProductQuality Create(ProductQuality pt)
 {
     pt.ObjectState = ObjectState.Added;
     _unitOfWork.Repository <ProductQuality>().Insert(pt);
     return(pt);
 }
Beispiel #13
0
        public ActionResult Post(ProductQuality vm)
        {
            ProductQuality pt = vm;

            if (ModelState.IsValid)
            {
                if (vm.ProductQualityId <= 0)
                {
                    pt.CreatedDate  = DateTime.Now;
                    pt.ModifiedDate = DateTime.Now;
                    pt.CreatedBy    = User.Identity.Name;
                    pt.ModifiedBy   = User.Identity.Name;
                    pt.ObjectState  = Model.ObjectState.Added;
                    _ProductQualityService.Create(pt);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        ViewBag.id   = vm.ProductTypeId;
                        ViewBag.Name = new ProductTypeService(_unitOfWork).Find(vm.ProductTypeId).ProductTypeName;
                        return(View("Create", vm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductQuality).DocumentTypeId,
                        DocId        = pt.ProductQualityId,
                        ActivityType = (int)ActivityTypeContants.Added,
                    }));

                    return(RedirectToAction("Create", new { id = vm.ProductTypeId }).Success("Data saved successfully"));
                }
                else
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();
                    ProductQuality          temp    = _ProductQualityService.Find(pt.ProductQualityId);

                    ProductQuality ExRec = Mapper.Map <ProductQuality>(temp);

                    temp.ProductQualityName = pt.ProductQualityName;
                    temp.IsActive           = pt.IsActive;
                    temp.ModifiedDate       = DateTime.Now;
                    temp.ModifiedBy         = User.Identity.Name;
                    temp.ObjectState        = Model.ObjectState.Modified;
                    _ProductQualityService.Update(temp);

                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = ExRec,
                        Obj   = temp,
                    });
                    XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        ViewBag.id   = pt.ProductTypeId;
                        ViewBag.Name = new ProductTypeService(_unitOfWork).Find(pt.ProductTypeId).ProductTypeName;
                        return(View("Create", pt));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductQuality).DocumentTypeId,
                        DocId           = temp.ProductQualityId,
                        ActivityType    = (int)ActivityTypeContants.Modified,
                        xEModifications = Modifications,
                    }));

                    return(RedirectToAction("Index", new { id = pt.ProductTypeId }).Success("Data saved successfully"));
                }
            }
            ViewBag.id   = vm.ProductTypeId;
            ViewBag.Name = new ProductTypeService(_unitOfWork).Find(vm.ProductTypeId).ProductTypeName;
            return(View("Create", vm));
        }