Example #1
0
 public void Update(CodeNotation product)
 {
     //if (ModelState.IsValid)
     //{
     iProp.Update(product);
     //}
 }
Example #2
0
 public void AddNew(CodeNotation product)
 {
     if (ModelState.IsValid)
     {
         iProp.Add(product);
     }
 }
Example #3
0
 public bool Delete(CodeNotation product)
 {
     try
     {
         if (product == null)
         {
             throw new ArgumentNullException("Notation cannot be null");
         }
         var codeProduct =
             ctx.CodeNotations.Where(x => x.StatusCode == "A")
             .First(x => x.NotationName == product.NotationName);
         codeProduct.StatusCode = "D";
         codeProduct.UpdateDate = DateTime.Parse(DateTime.Now.ToShortDateString());
         ctx.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         logger.Log(LogLevel.Error, ex.GetBaseException());
         return(false);
     }
 }
Example #4
0
 public bool Update(CodeNotation product)
 {
     try
     {
         if (product == null)
         {
             throw new ArgumentNullException("Notation cannot be null");
         }
         var codeProduct = ctx.CodeNotations.Single(x => x.CodeNotationsId == product.CodeNotationsId);
         codeProduct.NotationName        = product.NotationName;
         codeProduct.NotationDescription = product.NotationDescription;
         codeProduct.NotationURL         = product.NotationURL;
         codeProduct.CodeSnippet         = product.CodeSnippet;
         codeProduct.StatusCode          = product.StatusCode;
         codeProduct.UpdateDate          = DateTime.Parse(DateTime.Now.ToShortDateString());
         ctx.SaveChanges();
         return(true);
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                               eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                   ve.PropertyName, ve.ErrorMessage);
             }
         }
         throw;
     }
     catch (Exception ex)
     {
         logger.Log(LogLevel.Error, ex.GetBaseException());
         return(false);
     }
 }
Example #5
0
 public bool Add(CodeNotation product)
 {
     try
     {
         if (product == null)
         {
             throw new ArgumentNullException("Notation cannot be null");
         }
         DateTime tempDate;
         var      results = DateTime.TryParse(product.UpdateDate.ToShortDateString(), out tempDate);
         if (results)
         {
             ctx.CodeNotations.Add(product);
             ctx.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         logger.Log(LogLevel.Error, ex.GetBaseException());
         return(false);
     }
 }