Exemple #1
0
        public void EditPart(Parts part)
        {
            #region Vertification
            var errors = new NameValueCollection();

            if (errors.Count > 0) throw new RuleException(errors);
            #endregion

            context.Entry(Parts).State = EntityState.Modified;
            context.SaveChanges();
        }
Exemple #2
0
        public void SavePart(Parts part)
        {
            #region Vertification
            var errors = new NameValueCollection();

            if (errors.Count > 0) throw new RuleException(errors);
            #endregion

            if (part.PartID == null)
            {
                part.PartID = GenerateRandomCode.create_11();
            }
            context.Parts.Add(part);
            context.SaveChanges();
        }
Exemple #3
0
 public ActionResult edit(Parts part)
 {
     if(ModelState.IsValid)
     {
         try
         {
             repository.SavePart(part);
         }
         catch(RuleException ex)
         {
             ex.CopyToModelState(ModelState);
         }
     }
     return View();
 }