/// <summary> /// 保存头像 /// </summary> /// <param name="avatar">头像详细信息</param> /// <returns>true or false</returns> public bool Save(AvatarModel avatar) { using (var dbContext = new MissionskyOAEntities()) { var entity = dbContext.Avatars.Include(it => it.User).FirstOrDefault(item => (item.UserId == avatar.UserId)); if (entity != null) { entity.FileName = avatar.FileName; entity.Content = avatar.Content; entity.CreatedTime = DateTime.Now; } else { dbContext.Avatars.Add(avatar.ToEntity()); } dbContext.SaveChanges(); } return(true); }