Exemplo n.º 1
0
        public async Task <IHttpActionResult> PutAction(Guid id, CHM.Services.Models.Action action)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != action.ID)
            {
                return(BadRequest());
            }

            db.Entry(action).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ActionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public async Task <User> FindUserByEmailAndPassword(string email, string password)
        {
            var objUser = context.Users.Include("Users_Roles").Include("Users_Organizations").Include("Users_Roles.Role").Where(obj => obj.Email.Equals(email) && obj.Password.Equals(password)).FirstOrDefault();

            if (objUser != null)
            {
                DateTime?oldLogin = objUser.LastLogin;

                var LastLogin = Convert.ToDateTime(DateTime.Now);
                objUser.LastLogin = LastLogin.ToUniversalTime();

                context.Users.Attach(objUser);
                context.Entry(objUser).State = System.Data.Entity.EntityState.Modified;
                await context.SaveChangesAsync();

                objUser.LastLogin = oldLogin;

                return(objUser);
            }

            return(null);
        }
Exemplo n.º 3
0
 public Task CreateAsync(User user)
 {
     user.ID = Guid.NewGuid();
     context.Users.Add(user);
     return(context.SaveChangesAsync());
 }
Exemplo n.º 4
0
 public Task CreateAsync(Role role)
 {
     role.ID = Guid.NewGuid();
     context.Roles.Add(role);
     return(context.SaveChangesAsync());
 }