public EditViewModel(ResxDeltaReader resxDeltaReader, User user, string source) { _resxDeltaReader = resxDeltaReader; AvailableCultures = new List<string>(); Resources = new List<ResxKey>(); CurrentUser = user; CurrentSection = source; }
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("~/"); }
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("~/"); }
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("~/"); }