Exemple #1
0
 //
 // GET: /Social/User/
 public ActionResult List(string search, bool?departmentRequired)
 {
     using (var dbc = new FitFlowEntities()) {
         if (departmentRequired.HasValue && departmentRequired.Value)
         {
             var json = new {
                 data =
                     (from usr in dbc.UserView
                      join blg in dbc.Belongs on usr.Id equals blg.UserId
                      join grp in dbc.GroupView on blg.DepartmentId equals grp.Id
                      where usr.Name.Contains(search)
                      select new { usr.Id, usr.Name, DepartmentId = grp.Id, DepartmentName = grp.Name })
                     .ToArray()
                     .Select(u => new[] { u.DepartmentId, u.DepartmentName, u.Id, u.Name }),
                 head = new[] { "DepartmentId", "組織名", "UserId", "氏名" },
             };
             return(Json(json, JsonRequestBehavior.AllowGet));
         }
         else
         {
             var json = new {
                 data =
                     (from usr in dbc.UserView
                      where usr.Name.Contains(search)
                      select new { usr.Id, usr.Name })
                     .ToArray()
                     .Select(u => new[] { u.Id, u.Name }),
                 head = new[] { "UserId", "氏名" },
             };
             return(Json(json, JsonRequestBehavior.AllowGet));
         }
     }
 }
Exemple #2
0
 //
 // GET: /Social/User/
 public ActionResult Find(string search)
 {
     using (var dbc = new FitFlowEntities()) {
         var json = new {
             data = dbc.UserView.Select(u => new { UserId = u.Id, Name = u.Name }).ToArray(),
             head = new [] { "UserId", "Name" }
         };
         return(Json(json, JsonRequestBehavior.AllowGet));
     }
 }
 //
 // GET: /Social/Department/
 public ActionResult List(string search)
 {
     using (var dbc = new FitFlowEntities()) {
         var json = new {
             data = dbc.GroupView.Where(d => d.Name.Contains(search)).ToArray()
                    .Select(d => new[] { d.Id.ToString(), d.Name }),
             head = new[] { "DepartmentId", "組織名" }
         };
         return(Json(json, JsonRequestBehavior.AllowGet));
     }
 }
 //
 // GET: /Social/Department/
 public ActionResult Find(string id)
 {
     using (var dbc = new FitFlowEntities()) {
         var json = new {
             data = dbc.GroupView.Where(d => d.Id == id).ToArray()
                    .Select(d => new[] { d.Id, d.Name }).Single(),
             head = new[] { "DepartmentId", "組織名" }
         };
         return(Json(json, JsonRequestBehavior.AllowGet));
     }
 }
 public static void Transform(this FitFlowEntities @this, Action <FitFlowEntities> action)
 {
     using (var dbc = new FitFlowEntities()) {
         using (var tr = new TransactionScope(TransactionScopeOption.Required,
                                              new TransactionOptions {
             IsolationLevel = IsolationLevel.ReadCommitted
         })) {
             action(dbc);
             tr.Complete();
         }
     }
 }
Exemple #6
0
 public ActionResult Login(LoginFormsModel model, string returnUrl)
 {
     using (var dbc = new FitFlowEntities()) {
         var user = dbc.UserView.FirstOrDefault(u => u.Id == model.Id && u.Password == model.Password);
         if (user != null)
         {
             // ユーザー認証 成功
             FormsAuthentication.SetAuthCookie(model.Id, true);
             Session["LoginUser"] = user;
             return(this.Redirect(returnUrl ?? "/"));
         }
         else
         {
             // ユーザー認証 失敗
             this.ModelState.AddModelError(string.Empty, "指定されたユーザー名またはパスワードが正しくありません。");
             return(this.View(model));
         }
     }
 }