コード例 #1
0
        public IHttpActionResult PostCULGroup(CULGroupAndCULItems cULGroup)
        {
            if (cULGroup == null)
            {
                return(BadRequest("CUL object is not present the request body"));
            }
            try
            {
                cULGroup.CreatedDate = DateTime.Now;
                var newCULGroupId = cULsService.InsertCULGroup(cULGroup.AutoMapObject <CULGroupAndCULItems, CULGroup>());

                var culsIds = cULGroup.CULItemsIds;
                foreach (var culId in culsIds)
                {
                    cULsService.InsertCULGroupCULItem(new CULGroupCULs()
                    {
                        CreatedDate = DateTime.Now,
                        CULGroupId  = newCULGroupId,
                        CULItemId   = culId,
                        IsActive    = true
                    });
                }

                var groups = cULsService.GetCULGroups();
                var html   = Helpers.RenderPartial("~/Views/Shared/Partial/CULs/CULsGroupsList.cshtml", groups);
                return(Ok(html));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
コード例 #2
0
        public IHttpActionResult PutCULGroup(CULGroupAndCULItems group)
        {
            if (group == null)
            {
                return(BadRequest("CUL Group object is not present the request body"));
            }
            try
            {
                var original = cULsService.GetCULGroup(group.CULGroupId);
                group.CreatedDate = original.CreatedDate;
                group.CreatedBy   = original.CreatedBy;
                cULsService.UpdateCULGroup(group.AutoMapObject <CULGroupAndCULItems, CULGroup>());

                cULsService.DeleteCULGroupCULItemByGroupId(group.CULGroupId);
                var selectedGroupCuls = group.CULItemsIds;
                foreach (var selectedCULId in selectedGroupCuls)
                {
                    cULsService.InsertCULGroupCULItem(new CULGroupCULs()
                    {
                        CreatedDate = DateTime.Now,
                        CULGroupId  = group.CULGroupId,
                        CULItemId   = selectedCULId,
                        IsActive    = true
                    });
                }


                var culs = cULsService.GetCULGroups();
                var html = Helpers.RenderPartial("~/Views/Shared/Partial/CULs/CULsGroupsList.cshtml", culs);
                return(Ok(html));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }