예제 #1
0
        // PUT api/User/5
        public IHttpActionResult PutT3UsersLogin(string id, T3UsersLogin t3userslogin)
        {
            t3userslogin.ModifyDate = DateTime.Now;
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != t3userslogin.UserName)
            {
                return(BadRequest());
            }
            t3userslogin.Password        = L3CryptorEngine.Encrypt(t3userslogin.Password);
            db.Entry(t3userslogin).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!T3UsersLoginExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public IHttpActionResult PostT3UsersLogin(T3UsersLogin t3userslogin)

        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            // string url = t3usersloginExt.Url;
            t3userslogin.Password = L3CryptorEngine.Encrypt(t3userslogin.Password);
            var now = DateTime.Now;

            t3userslogin.ModifyDate          = now;
            t3userslogin.CreateDate          = now;
            t3userslogin.LastLogin           = null;
            t3userslogin.KeyStringValidEmail = L3Common.RandomString(25);
            db.T3UsersLogin.Add(t3userslogin);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (T3UsersLoginExists(t3userslogin.UserName))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }
            SendMail(t3userslogin);
            return(CreatedAtRoute("DefaultApi", new { id = t3userslogin.UserName }, t3userslogin));
        }