コード例 #1
0
ファイル: EditViewModel.cs プロジェクト: saxx/ResxWeb
        public EditViewModel(ResxDeltaReader resxDeltaReader, User user, string source)
        {
            _resxDeltaReader = resxDeltaReader;
            AvailableCultures = new List<string>();
            Resources = new List<ResxKey>();

            CurrentUser = user;
            CurrentSection = source;
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: saxx/ResxWeb
        public ActionResult Edit(string id)
        {
            var settings = LoadSettings();
            var source = settings.Sources.FirstOrDefault(x => x.Alias == id);
            if (source != null)
            {
                var reader = new ResxDeltaReader();

                var model = new EditViewModel(reader, LoadCurrentUser(), id);
                model.Fill(source.Path);
                reader.ReadDelta(model.Resources, ResxDeltaReader.GetDeltaDirectoryPath(User.Identity.Name, id));

                return View(model);
            }
            return Redirect("~/");
        }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: saxx/ResxWeb
        public ActionResult Edit(FormCollection form, string id)
        {
            var settings = LoadSettings();
            var source = settings.Sources.FirstOrDefault(x => x.Alias == id);
            if (source != null)
            {
                var reader = new ResxDeltaReader();
                var writer = new ResxDeltaWriter();

                var model = new EditViewModel(reader, LoadCurrentUser(), id);
                model.Fill(source.Path);

                writer.SaveDelta(model.Resources, form, ResxDeltaReader.GetDeltaDirectoryPath(User.Identity.Name, id));

                return RedirectToAction("Edit", new { id });
            }
            return Redirect("~/");
        }
コード例 #4
0
ファイル: HomeController.cs プロジェクト: saxx/ResxWeb
        public ActionResult Download(string id)
        {
            var settings = LoadSettings();
            var source = settings.Sources.FirstOrDefault(x => x.Alias == id);
            if (source != null)
            {
                var reader = new ResxDeltaReader();
                var writer = new ResxDeltaWriter();

                var model = new EditViewModel(reader, LoadCurrentUser(), id);
                model.Fill(source.Path);
                reader.ReadDelta(model.Resources, ResxDeltaReader.GetDeltaDirectoryPath(User.Identity.Name, id));

                var pathToArchive = writer.BuildArchive(source.Path, User.Identity.Name, source.Alias, model.Resources);
                return new FilePathResult(pathToArchive, "application/zip")
                    {
                        FileDownloadName = User.Identity.Name + "_" + id + "_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".zip"
                    };
            }
            return Redirect("~/");
        }