Skip to content

Instantly share code, notes, and snippets.

@odinserj
Created April 19, 2012 11:09
Show Gist options
  • Save odinserj/2420304 to your computer and use it in GitHub Desktop.
Save odinserj/2420304 to your computer and use it in GitHub Desktop.
[HttpGet]
[AvailableFor(UserRole.Administrator, UserRole.RegionalRepresentative)]
public ActionResult UnapprovedUser(string id)
{
var user = ModelContext.GetService<User>().Get(id);
return View(new UnapprovedUserViewModel { Operand = user });
}
[HttpPost, AutoTransaction]
[AvailableFor(UserRole.Administrator, UserRole.RegionalRepresentative)]
public ActionResult UnapprovedUser(string id, UnapprovedUserViewModel model)
{
var user = ModelContext.GetService<User>().Get(id);
var provider = ModelContext.Get<ChangeSetBuilder>();
provider.CreateChangeSet(user, model);
if (ModelContext.ValidationContext.IsValid)
{
FlashMessage = "Данные успешно обновлены";
return RedirectToAction<ChangeSetController>(c => c.UnapprovedUser(id));
}
FlashMessage = "error|Данные не были обновлены";
model.Operand = user;
return View(model);
}
[HttpGet]
[AvailableFor(UserRole.Administrator, UserRole.RegionalRepresentative)]
public ActionResult UnapprovedOrganization(int id)
{
var organization = ModelContext.GetService<Organization>().Get(id);
return View(new UnapprovedOrganizationViewModel { Operand = organization });
}
[HttpPost, AutoTransaction]
[AvailableFor(UserRole.Administrator, UserRole.RegionalRepresentative)]
public ActionResult UnapprovedOrganization(int id, UnapprovedOrganizationViewModel model)
{
var organization = ModelContext.GetService<Organization>().Get(id);
var provider = this.ModelContext.Get<ChangeSetBuilder>();
provider.CreateChangeSet(organization, model);
if (this.ModelContext.ValidationContext.IsValid)
{
FlashMessage = "Данные успешно обновлены";
return RedirectToAction<ChangeSetController>(c => c.UnapprovedOrganization(id));
}
FlashMessage = "error|Данные не были обновлены";
model.Operand = organization;
return View(model);
}
[HttpGet]
[AvailableFor(UserRole.Administrator, UserRole.RegionalRepresentative)]
public ActionResult UnapprovedFederation(int id)
{
var federation = ModelContext.GetService<Federation>().Get(id);
var model = new UnapprovedFederationViewModel { Operand = federation };
return View(model);
}
[HttpPost, AutoTransaction]
[AvailableFor(UserRole.Administrator, UserRole.RegionalRepresentative)]
public ActionResult UnapprovedFederation(int id, UnapprovedFederationViewModel model)
{
var federation = ModelContext.GetService<Federation>().Get(id);
var provider = ModelContext.Get<ChangeSetBuilder>();
provider.CreateChangeSet(federation, model);
if (ModelContext.ValidationContext.IsValid)
{
FlashMessage = "Данные успешно обновлены";
return RedirectToAction<ChangeSetController>(c => c.UnapprovedFederation(id));
}
FlashMessage = "error|Данные не были обновлены";
model.Operand = federation;
return View(model);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment