示例#1
0
        public EditViewModel(ResxDeltaReader resxDeltaReader, User user, string source)
        {
            _resxDeltaReader = resxDeltaReader;
            AvailableCultures = new List<string>();
            Resources = new List<ResxKey>();

            CurrentUser = user;
            CurrentSection = source;
        }
示例#2
0
        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
        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
        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("~/");
        }