public void Update(CodeNotation product) { //if (ModelState.IsValid) //{ iProp.Update(product); //} }
public void AddNew(CodeNotation product) { if (ModelState.IsValid) { iProp.Add(product); } }
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); } }
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); } }
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); } }