public ActionResult <CreateSignDto> AddSign(CreateSignDto targetValue) { using (var transaction = dataContext.Database.BeginTransaction()) { string[] colorOptions = { "red", "green", "yellow", "blue", "black", "sparkly gold", "sparkly pink", "teal", "orange" }; String checkedColor = ""; for (int i = 0; i < colorOptions.Length; i++) { if (targetValue.color.ToLower().Equals(colorOptions[i])) { checkedColor = colorOptions[i]; } } var data = dataContext.Set <Sign>().Add(new Sign { emoji = targetValue.emoji, color = checkedColor, content = targetValue.content, stock = targetValue.stock }); dataContext.SaveChanges(); transaction.Commit(); return(Created($"api/sign/{data.Entity.Id}", targetValue)); } }
//[Authorize(Roles = Roles.Admin)] public ActionResult <CreateSignDto> AddSign(CreateSignDto targetValue) { var data = dataContext.Set <Sign>().Add(new Sign { emoji = targetValue.emoji, color = targetValue.color, content = targetValue.content, stock = targetValue.stock }); dataContext.SaveChanges(); return(Created($"api/sign/{data.Entity.Id}", targetValue)); }