Beispiel #1
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("~/");
        }
Beispiel #2
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("~/");
        }
Beispiel #3
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("~/");
        }