public static Help ToDataModel(this Contracts.Help.CreateHelpEntry create) { var dataModel = new Help { Language = create.Language, Slug = create.Slug, Title = create.Title, Description = create.Description, CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now, }; return(dataModel); }
public Contracts.Help.HelpEntry Create(Contracts.Help.CreateHelpEntry create) { using (var db = new RAAPMasterEntities()) { if (db.Helps.Any(a => a.Slug == create.Slug && a.Language == create.Language)) { throw new RAAPConflictException("Slug & language combination is already in use!"); } var help = create.ToDataModel(); db.Helps.Add(help); db.SaveChanges(); return(db.Helps.FirstOrDefault(u => u.HelpId == help.HelpId).ToContract()); } }
public IHttpActionResult Post([FromBody] Contracts.Help.CreateHelpEntry create) { var result = HelpService.Create(create); return(Ok(result)); }