コード例 #1
0
        public HttpResponseMessage Upsert(ItemViewModel item)
        {
            if (item.Id > 0)
            {
                var t = Update(item);
                return Request.CreateResponse(System.Net.HttpStatusCode.NoContent);
            }
            else
            {
                var t = Create(item);
                return Request.CreateResponse(t.ItemId);
            }

        }
コード例 #2
0
        private Item Create(ItemViewModel item)
        {
            Item t = new Item
            {
                ItemName = item.Name,
                ItemDescription = item.Description,
                AssignedUserId = item.AssignedUser,
                ModuleId = ActiveModule.ModuleID,
                CreatedByUserId = UserInfo.UserID,
                LastModifiedByUserId = UserInfo.UserID,
                CreatedOnDate = DateTime.UtcNow,
                LastModifiedOnDate = DateTime.UtcNow
            };
            _repository.AddItem(t);

            return t;
        }
コード例 #3
0
        public HttpResponseMessage Get(int itemId)
        {
            var item = new ItemViewModel(_repository.GetItem(itemId, ActiveModule.ModuleID));

            return Request.CreateResponse(item);
        }
コード例 #4
0
        private Item Update(ItemViewModel item)
        {

            var t = _repository.GetItem(item.Id, ActiveModule.ModuleID);
            if (t != null)
            {
                t.ItemName = item.Name;
                t.ItemDescription = item.Description;
                t.AssignedUserId = item.AssignedUser;
                t.LastModifiedByUserId = UserInfo.UserID;
                t.LastModifiedOnDate = DateTime.UtcNow;
            }
            _repository.UpdateItem(t);

            return t;
        }