/// <summary> /// /// </summary> /// <param name="u"></param> /// <returns></returns> public static User SaveUser(User u) { using (EntityContext ctx = new EntityContext()) { u.Email = u.Email.ToLower(); u.ValidateAndRaise(); u.CreatedAt = u.CreatedAt.ToCommonTime(); if (u.UserId == 0) { u.Password = Crypto.GetSHA1(u.Password); ctx.Users.AddObject(u); } else { ctx.Users.Attach(u); } ctx.SaveChanges(); return(u); } }