コード例 #1
0
        public object Put([FromBody] ContentLimitItemPoco poco)
        {
            var model = poco.ToModel();

            if (!model.IsValid)
            {
                return(new
                {
                    isSuccess = false,
                    messages = model.ValidationResults()
                });
            }

            using (var dal = new DalService())
            {
                dal.Update(poco);
                dal.SaveChanges();

                return(new { isSuccess = true, record = poco });
            }
        }
コード例 #2
0
        public object Delete(string guid)
        {
            using (var dal = new DalService())
            {
                var existingItem = dal.ContentLimitItems
                                   .FirstOrDefault(r => r.Guid.Equals(guid, StringComparison.OrdinalIgnoreCase));

                if (existingItem == null)
                {
                    return(new
                    {
                        isSuccess = false,
                        messages = new string[] { "Could not find item to delete" }
                    });
                }

                dal.Remove(existingItem);
                dal.SaveChanges();

                return(new { isSuccess = true });
            }
        }