Esempio n. 1
0
        public ActionResult AddVersion(VersionsViewModel versionsViewModel)
        {
            versionsViewModel.Version.LogDate = DateTime.Now;
            versionsViewModel.Version.Created = DateTime.Now;

            if (!ModelState.IsValid)
            {
                versionsViewModel.GetTemplateVersionsAndCompanies();
                return(View(versionsViewModel));
            }

            if (versionsViewModel.Version.DeletedBool)
            {
                versionsViewModel.Version.DeletedString = "A";
            }
            else
            {
                versionsViewModel.Version.DeletedString = "N";
            }

            if (versionsViewModel.Version.LogFlagBool)
            {
                versionsViewModel.Version.LogFlagString = "A";
            }
            else
            {
                versionsViewModel.Version.LogFlagString = "N";
            }

            long versionId = 0;

            TempData["result"] = versionsViewModel.AddVersion(versionsViewModel.Version, ref versionId);
            return(RedirectToAction("GetVersion", new { idVersion = versionId }));
        }
        /// <summary>
        /// The get view model.
        /// </summary>
        /// <param name="page">
        /// The page number.
        /// </param>
        /// <returns>
        /// The <see cref="VersionsViewModel"/> ready for use.
        /// </returns>
        protected VersionsViewModel GetViewModel(int page)
        {
            var list = this.Repository.GetAll().Where(v => !v.ExpirationDate.HasValue ||
                                                      v.ExpirationDate.Value > DateTime.Now).ToList();

            Uri contextUri = System.Web.HttpContext.Current.Request.Url;

            var baseUri = string.Format(
                "{0}://{1}{2}",
                contextUri.Scheme,
                contextUri.Host,
                contextUri.Port == 80 ? string.Empty : ":" + contextUri.Port);

            foreach (var version in list)
            {
                var localUrl = this.Url.Action("Get", new { id = version.Id });
                version.DownloadUrl = string.Format("{0}{1}", baseUri, VirtualPathUtility.ToAbsolute(localUrl));
            }

            var viewModel = new VersionsViewModel
            {
                Versions = list
                           .OrderByDescending(v => v.Id, new VersionStringHelper.VersionStringComparer())
                           .Skip((page - 1) * this.PageSize)
                           .Take(this.PageSize).ToList(),
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = this.PageSize,
                    TotalItems   = list.Count()
                }
            };

            return(viewModel);
        }
        public ActionResult db_Create([DataSourceRequest] DataSourceRequest request, VersionsViewModel db)
        {
            if (db != null && ModelState.IsValid)
            {
                VersionsService.Create(db);
            }

            return(Json(new[] { db }.ToDataSourceResult(request, ModelState)));
        }
Esempio n. 4
0
        public ActionResult GetTemplateVersion(VersionsViewModel versionsViewModel)
        {
            if (versionsViewModel.TemplateVersionId == 0)
            {
                TempData["result"] = "Nebyl vybrán vzor";
                return(RedirectToAction("AddVersion"));
            }

            versionsViewModel.GetTemplateVersion(versionsViewModel.TemplateVersionId);
            versionsViewModel.GetTemplateVersionsAndCompanies();
            return(View("AddVersion", versionsViewModel));
        }
        public ActionResult DetailsRegisterItemVersions(string registername, string parentRegister, string itemname, string registerItemOwner, string format)
        {
            var redirectToApiUrl = RedirectToApiIfFormatIsNotNull(format);

            if (!string.IsNullOrWhiteSpace(redirectToApiUrl))
            {
                return(Redirect(redirectToApiUrl));
            }

            var versionsItem = _versioningService.Versions(registername, parentRegister, itemname);
            var model        = new VersionsViewModel(versionsItem);

            model.AccessCreateNewVersions           = _accessControlService.AccessCreateNewVersion(model.CurrentVersion);
            model.CurrentVersion.AccessRegisterItem = _accessControlService.Access(model.CurrentVersion);

            ViewBag.registerItemOwner = registerItemOwner;
            return(View(model));
        }
Esempio n. 6
0
 public ActionResult AddVersion(VersionsViewModel versionToDB)
 {
     TempData["result"] = versionsViewModel.AddVersion(versionToDB.Version);
     return(RedirectToAction("GetTodayVersions"));
 }
        public ActionResult db_Destroy([DataSourceRequest] DataSourceRequest request, VersionsViewModel db)
        {
            if (db != null)
            {
                VersionsService.Destroy(db);
            }

            return(Json(new[] { db }.ToDataSourceResult(request, ModelState)));
        }