示例#1
0
 public ActionResult Update(Bam.Net.UserAccounts.Data.User dao)
 {
     try
     {
         dao.Save();
         return(Json(new { Success = true, Message = "", Dao = dao.ToJsonSafe() }));
     }
     catch (Exception ex)
     {
         return(GetErrorResult(ex));
     }
 }
示例#2
0
        public void TestTheSetup()
        {
            ApplicationRegistryService svc = GetTestService();
            string userName = 8.RandomLetters();
            User   user     = SetCurrentUser(userName, svc);

            Expect.AreEqual(userName, user.UserName);
            User sessionUser = Session.Get(svc.HttpContext).UserOfUserId;

            Expect.IsNotNull(sessionUser);
            Expect.AreEqual(userName, sessionUser.UserName, "UserName didn't match");
            Expect.AreEqual(sessionUser, svc.CurrentUser, "Users didn't match");
        }
示例#3
0
 public ActionResult Delete(long id)
 {
     try
     {
         string msg = "";
         Bam.Net.UserAccounts.Data.User dao = Bam.Net.UserAccounts.Data.User.OneWhere(c => c.KeyColumn == id);
         if (dao != null)
         {
             dao.Delete();
         }
         else
         {
             msg = string.Format("The specified id ({0}) was not found in the table (User)", id);
         }
         return(Json(new { Success = true, Message = msg, Dao = "" }));
     }
     catch (Exception ex)
     {
         return(GetErrorResult(ex));
     }
 }
示例#4
0
        private static User SetCurrentUser(string userName, ApplicationRegistryService svc)
        {
            IHttpContext ctx = Substitute.For <IHttpContext>();

            ctx.Request = Substitute.For <IRequest>();
            ctx.Request.Url.Returns(new Uri("http://test.cxm"));
            NameValueCollection headers = new NameValueCollection();

            headers["REMOTE_ADDR"] = "127.0.0.1";
            ctx.Request.Headers.Returns(headers);
            ctx.Response = Substitute.For <IResponse>();
            CookieCollection Cookies       = new CookieCollection();
            Cookie           sessionCookie = new Cookie(Session.CookieName, "0368c7fde0a40272d42e14e224d37761dbccef665116ccb063ae31aaa7708d72");

            Cookies.Add(sessionCookie);
            ctx.Request.Cookies.Returns(Cookies);
            ctx.Response.Cookies.Returns(Cookies);
            svc.HttpContext = ctx;
            SessionCollection sessions = Session.LoadAll();

            sessions.Delete();
            UserCollection users = User.LoadAll();

            users.Delete();
            User    result  = User.Create(userName);
            Session session = Session.Get(ctx);

            session.UserId = result.Id;
            session.Save();
            IEnumerable <Organization> organizations = svc.ApplicationRegistrationRepository.RetrieveAll <Organization>();

            organizations.Each(o => svc.ApplicationRegistrationRepository.Delete(o));
            Expect.AreEqual(0, svc.ApplicationRegistrationRepository.RetrieveAll <Organization>().Count());
            IEnumerable <ApplicationRegistration.Data.Application> apps = svc.ApplicationRegistrationRepository.RetrieveAll <ApplicationRegistration.Data.Application>();

            apps.Each(a => svc.ApplicationRegistrationRepository.Delete(a));
            Expect.AreEqual(0, svc.ApplicationRegistrationRepository.RetrieveAll <ApplicationRegistration.Data.Application>().Count());
            svc.ApplicationRegistrationRepository.RetrieveAll <Machine>().Each(h => svc.ApplicationRegistrationRepository.Delete(h));
            return(result);
        }
示例#5
0
 public ActionResult Create(Bam.Net.UserAccounts.Data.User dao)
 {
     return(Update(dao));
 }