Ejemplo n.º 1
0
        //public static bool UpdatePages() {
        //    var pages = Unity.Work.Repository<tbl_dummy_page>().GetAll().ToList();
        //    int i = 3;
        //    foreach (var page in pages)
        //    {
        //        page.page_name = "Page";
        //        page.page_number = i;
        //        i++;
        //        Unity.Work.Repository<tbl_dummy_page>().Update(page);
        //    }
        //    Unity.Work.Save();
        //    return true;

        //}

        public static FolioLoadViewModel CreateDummyFolio(FolioViewMode folio, int pub_id, int iss_id)
        {
            using (ClientDataContext context = new ClientDataContext())
            {
                var newfolio = new tbl_dummy_folio
                {
                    dummy_page_dimension_id = context.lu_dummy_page_dimension.Where(x => x.pub_id == pub_id).FirstOrDefault().dummy_page_dimension_id,
                    total_page        = folio.total_page,
                    start_page_number = folio.start_page_number,
                    iss_id            = iss_id,
                    page_sequence     = folio.start_page_number,
                    is_deleted        = folio.is_deleted,
                    folio_name        = folio.folio_name
                };
                context.tbl_dummy_folio.Add(newfolio);
                // UpdateFolioSequence(newfolio, folio.insertAt, folio.folioAt, context);
                context.SaveChanges();
                var result = new FolioLoadViewModel();
                result.pages = new List <DummyPageViewModel>();
                result.pages = CreatePages(folio.total_page.GetValueOrDefault(), folio.start_page_number.GetValueOrDefault(), newfolio.dummy_folio_id, folio.page_desc).Select(pl => new DummyPageViewModel
                {
                    dummy_page_id = pl.dummy_page_id,
                    page_number   = pl.page_number.GetValueOrDefault(),
                    page_name     = pl.page_name,
                    page_note     = pl.page_note,
                    page_status   = pl.page_status,
                    is_deleted    = pl.is_deleted.GetValueOrDefault()
                }).ToList();
                result.folio_id       = newfolio.dummy_folio_id;
                result.folio_name     = newfolio.folio_name;
                result.folio_sequence = newfolio.page_sequence.GetValueOrDefault();
                return(result);
            }
        }
Ejemplo n.º 2
0
        public HttpResponseMessage UpdateFolioName(HttpRequestMessage request, FolioViewMode folio)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                if (!ModelState.IsValid)
                {
                    response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var currentFolio = _dummyFolioRepository.GetSingle(folio.dummy_folio_id);
                    if (currentFolio != null)
                    {
                        currentFolio.folio_name = folio.folio_name;
                        _unitOfWork.Commit();
                        response = request.CreateResponse(HttpStatusCode.OK, true);
                    }
                    else
                    {
                        response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                    }
                }
                return response;
            }));
        }