예제 #1
0
 public ActionResult Index(int? page, string selectedUsers, string diselectedUsers)
 {
     int pageNumber = page.HasValue ? page.Value : 1;
     UnitOfWork uof = new UnitOfWork(provider);
     var users = provider.GetAllUsers();
     if (users.Count() == 0)
     {
         return RedirectToAction("Step1");
     }
     string url = "http://" + Request.Url.Authority + "/Home/Index";
     Paging pagingModel = PagingHelper.GetPagingModel(pageNumber, users.Count(), this.usersPerPage, url);
     ValueListIterator iterator = new ValueListIterator(provider, usersPerPage);
     List<User> pagedUsers = iterator.GetCurrentElement(pageNumber);
     int[] selected = null;
     int[] diselected;
     diselected = ResolveSelections(selectedUsers, diselectedUsers, ref selected);
     UrlOptions options = new UrlOptions()
     {
         UpdateUrl = String.Format("http://{0}/Home/UpdateRecord", Request.Url.Authority)
     };
     SetChecked(pagedUsers, (int[])Session["selectedUsers"]);
     XmlDocument xml = XMLUserWriter.WriteXML(pagedUsers, pagingModel, options);
     string html = XSLTConverter.TransformFromMemory(xml, Server.MapPath(Url.Content("~/Converters/paging.xsl")));
     return Content(html);
 }
예제 #2
0
 public ActionResult DeleteRecord(int? page, string selectedUsers, string diselectedUsers)
 {
     UnitOfWork uof = new UnitOfWork(provider);
     int[] selected = null;
     int[] diselected;
     if (!String.IsNullOrEmpty(selectedUsers) || !String.IsNullOrEmpty(diselectedUsers))
     {
         selected = selectedUsers.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(item => Int32.Parse(item)).ToArray();
         diselected = diselectedUsers.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(item => Int32.Parse(item)).ToArray();
         if (Session["selectedUsers"] != null)
         {
             int[] saved = (int[])Session["selectedUsers"];
             selected = saved.Union(selected).Except(diselected).ToArray();
         }
         foreach (var id in selected)
         {
             uof.RegisterDeleted(id);
         }
     }
     uof.Commit();
     return RedirectToAction("Index");
 }
예제 #3
0
 public void UpdateRecord(User user)
 {
     UnitOfWork uof = new UnitOfWork(provider);
     uof.RegisterDirty(user);
     uof.Commit();
 }
예제 #4
0
 public ActionResult PostStep2(string phone, string address)
 {
     UnitOfWork uof = new UnitOfWork(provider);
     DomainModel.Models.User user = TempData["Model"] as User;
     user.Phone = phone;
     user.Address = address;
     uof.RegisterNew(user);
     uof.Commit();
     return RedirectToAction("Index");
 }