Пример #1
0
        private bool Validate(Template template)
        {
            ValidationErrors.Clear();

            if (!string.IsNullOrEmpty(template.HeaderText))
            {
                if (template.HeaderText.ToLower() ==
                    template.HeaderText)
                {
                    ValidationErrors.Add(new
                        KeyValuePair<string, string>("Header Text",
                            "Header must not be all lower case."));
                }
            }

            return (ValidationErrors.Count == 0);
        }
Пример #2
0
        public bool Update(Template template)
        {
            bool ret = false;

            ret = Validate(template);

            if (ret)
            {
                // TODO: Create UPDATE code here
                using (var db = new AppContext())
                {
                    db.Templates.AddOrUpdate(template);
                    db.SaveChanges();
                }
            }

            return ret;
        }
 public IHttpActionResult Post(Template vm)
 {
     db.Templates.AddOrUpdate(vm);
     db.SaveChanges();
     return Ok(vm);
 }