Example #1
0
 public static ControlCategory ToDataModel(this Contracts.ControlCategory.CreateControlCategory create)
 {
     return(new ControlCategory
     {
         Name = create.Name,
         Description = create.Description,
         CreatedOn = DateTime.Now,
         UpdatedOn = DateTime.Now,
     });
 }
Example #2
0
        public Contracts.ControlCategory.ControlCategory Create(Contracts.ControlCategory.CreateControlCategory createControlCategory)
        {
            using (var db = new RAAPEntities(GetConnectionString()))
            {
                if (db.ControlCategories.Any(a => a.Name == createControlCategory.Name))
                {
                    throw new RAAPConflictException("Name is already in use, please try another name.");
                }
                var ControlCategory = createControlCategory.ToDataModel();
                db.ControlCategories.Add(ControlCategory);
                db.SaveChanges();

                return(ControlCategory.ToContract());
            }
        }
Example #3
0
 public IHttpActionResult Post([FromBody] Contracts.ControlCategory.CreateControlCategory create)
 {
     ControlCategoryService.Create(create);
     return(Ok());
 }