Пример #1
0
 private async Task CreateContact(List <User> ListContactOnline, UserRepository userRepository)
 {
     foreach (var item in ListContactOnline)
     {
         #region Convert Models.User to UserLite
         UserLite userLite = new UserLite();
         userLite.BloodType     = item.BloodType;
         userLite.CellPhone     = item.CellPhone;
         userLite.CreatedTime   = item.CreatedTime;
         userLite.DayOfBirth    = item.DayOfBirth;
         userLite.DesktopPhone  = item.DesktopPhone;
         userLite.Gender        = item.Gender;
         userLite.GPSCreateTime = item.GPSCreateTime;
         userLite.Latitude      = item.Latitude;
         userLite.LocationId    = item.Location.LocationId;
         userLite.LocationName  = item.Location.Name;
         userLite.Longitude     = item.Longitude;
         userLite.Name          = item.Name;
         userLite.ObjectId      = item.ObjectId;
         userLite.Password      = item.Password;
         userLite.Position      = item.Position;
         userLite.Role          = item.Role;
         userLite.SecretCode    = item.SecretCode;
         userLite.Status        = item.Status;
         userLite.UserId        = item.UserId;
         #endregion
         userRepository.Create(userLite);
     }
 }
Пример #2
0
        public static List <UserLite> ConvertToListUserLite(this List <Models.User> users)
        {
            List <UserLite> UserLites = new List <UserLite>();

            foreach (var item in users)
            {
                UserLite userLite = new UserLite();
                userLite.BloodType     = item.BloodType;
                userLite.CellPhone     = item.CellPhone;
                userLite.CreatedTime   = item.CreatedTime;
                userLite.DayOfBirth    = item.DayOfBirth;
                userLite.DesktopPhone  = item.DesktopPhone;
                userLite.Gender        = item.Gender;
                userLite.GPSCreateTime = item.GPSCreateTime;
                userLite.Latitude      = item.Latitude;
                userLite.LocationId    = item.Location != null ? item.Location.LocationId : 0;
                userLite.LocationName  = item.Location != null ? item.Location.Name : "";
                userLite.Longitude     = item.Longitude;
                userLite.Name          = item.Name;
                userLite.ObjectId      = item.ObjectId;
                userLite.Password      = item.Password;
                userLite.Position      = item.Position;
                userLite.Role          = item.Role;
                userLite.SecretCode    = item.SecretCode;
                userLite.Status        = item.Status;
                userLite.UserId        = item.UserId;
                UserLites.Add(userLite);
            }
            return(UserLites);
        }
Пример #3
0
        public object UpdateUser([FromBody] UserLite user)
        {
            #region Try Block
            try
            {
                #region Functionality
                string scopeKey = null;
                scopeKey = UserLite.Update(user, out int statusCode);
                return(statusCode);

                #endregion Functionality
            }

            #endregion Try Block

            #region Catch Block

            catch (Exception exception)
            {
                #region Body
                return(exception);

                #endregion Body
            }

            #endregion Catch Block
        }
Пример #4
0
        private async void DeleteItem_Clicked(object sender, EventArgs e)
        {
            App.localizer.SetLocale(App.defaultCulture);
            var answer = await DisplayAlert(App.localizeResProvider.GetText("String177"), App.localizeResProvider.GetText("String176"), App.localizeResProvider.GetText("Yes1"), App.localizeResProvider.GetText("No1"));

            if (answer)
            {
                RestClient restClient = App.restClient;
                var        result     = await restClient.DeleteAsync("users", user.UserId);

                if (result == ApiStatusConstant.SUCCESS)
                {
                    UserLite userLite = App.UserLites.Where(x => x.UserId.Equals(user.UserId)).FirstOrDefault();
                    if (userLite != null)
                    {
                        var repository = App.Get <UserRepository>();
                        repository.Delete(userLite);
                    }
                    App.UserLites = App.UserLites.Where(x => !x.UserId.Equals(user.UserId)).ToList();

                    restClient.AddEvent("DELETE_USER");
                    await DisplayAlert(App.localizeResProvider.GetText("Notification"), App.localizeResProvider.GetText("String178"), "Ok");

                    var existingPages = Navigation.NavigationStack.ToList();
                    for (int i = 1; i < existingPages.Count; i++)
                    {
                        Navigation.RemovePage(existingPages[i]);
                    }
                }
                else
                {
                    await DisplayAlert(App.localizeResProvider.GetText("Notification"), App.localizeResProvider.GetText("String179"), "Ok");
                }
            }
        }
Пример #5
0
 public ChatConversationViewModel()
 {
     Title       = "Chat";
     PreLoadData = new Command(() => { ApiUrl = $"api/chat/conversation?userid={UserLogged.Id}&Page={Page}"; });
     Sender      = new UserLite {
         Id = UserLogged.Id, FullName = UserLogged.FullName, PictureUrl = UserLogged.AvatarUrl
     };
     Initilize();
 }
 private void RestoreDeletedRequester(UserLite userFrom)
 {
     if (userFrom.UserType == UserType.Requester && userFrom.DeleteDate != null)
     {
         Send(new UpdateRequesterCommand(new RequesterDTO {
             ID = userFrom.Id, DeleteDate = null
         },
                                         new Enum[] { RequesterField.DeleteDate }));
     }
 }
        private static void AssertRequesterMadeAlive(UserLite requester)
        {
            var updateCommand = Context.Transport.TpQueue.GetMessages <UpdateCommand>().Where(x => x.Dto is RequesterDTO).First();

            updateCommand.ChangedFields.Should(Be.EquivalentTo(new[] { RequesterField.DeleteDate.ToString() }));
            var requesterDto = (RequesterDTO)updateCommand.Dto;

            requesterDto.DeleteDate.Should(Be.Null);

            requesterDto.ID.Should(Be.EqualTo(requester.Id));
        }
Пример #8
0
 //public Message CreateMessage(Message message, Chat chat, ref IMessageRepository messageRepo)
 //{
 //	return new Message
 //	{
 //		id = NextAvailableID(ref messageRepo),
 //		user_id = chat.user_id,
 //		chat_id = chat.id,
 //		message = message.message,
 //		created = message.created,
 //	};
 //}
 public MessageResponse CreateMessageResponse(Message message, UserLite user)
 {
     return(new MessageResponse
     {
         id = message.id,
         user_id = message.user_id,
         chat_id = message.chat_id,
         message = message.message,
         created = message.created,
         user = user
     });
 }
Пример #9
0
 public ChatResponse CreateChatResponse(Chat chat, UserLite user, Message message)
 {
     return(new ChatResponse
     {
         id = chat.id,
         user_id = chat.user_id,
         name = chat.name,
         created = chat.created,
         user = user,
         last_message = message
     });
 }
 public void Handle(UserQueryResult message)
 {
     Data.AllUsersCount = message.QueryResultCount;
     if (message.Dtos != null)
     {
         Data.UsersRetrievedCount += message.Dtos.Length;
         foreach (var userDto in message.Dtos)
         {
             AddUserLite(UserLite.Create(userDto));
         }
     }
     CompleteSagaIfNecessary();
 }
Пример #11
0
        private async Task Login()
        {
            string receivedUserName = reader.ReadLine();
            string receivedPassword = reader.ReadLine();

            UserLite tmpUser = new UserLite(await model.Login(receivedUserName, receivedPassword));

            try
            {
                string tmpUserSerialize = JsonSerializer.Serialize(tmpUser);
                writer.WriteLine(tmpUserSerialize);
            } catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }
        }
Пример #12
0
        public IHttpActionResult Create(int chat_id, [FromBody] MessageRequest message)        //needs to respect pagination
        {
            if (Request.Headers.Contains("Authorization"))
            {
                try
                {
                    string token = Request.Headers.GetValues("Authorization").First();

                    JwtSecurityToken jwt            = new JwtSecurityToken(token);
                    User             authorizedUser = _users.FindUserByToken(jwt);
                    if (authorizedUser == null)
                    {
                        return(Unauthorized());
                    }
                    if (message == null)
                    {
                        return(BadRequest("Your message is empty.  Please try again."));
                    }
                    var associatedChat = _chats.FindChatById(chat_id, authorizedUser);                    //verify it belongs to the user
                    if (associatedChat.Entity != null)
                    {
                        var m = _messageFactory.CreateMessage(message, associatedChat.Entity, authorizedUser, ref _messages);

                        var result = _messages.Create(associatedChat.Entity, m);

                        if (result.Status == RepositoryActionStatus.Created)
                        {
                            var liteAuthorizedUser = new UserLite {
                                id = authorizedUser.id, name = authorizedUser.name
                            };
                            var newMessageResponse = _messageFactory.CreateMessageResponse(result.Entity, liteAuthorizedUser);
                            var response           = _responseFactory.CreateResponse(newMessageResponse);
                            return(Ok(response));
                        }
                    }

                    return(BadRequest("You do not have access to create a message for the specified chat_id"));
                }
                catch (Exception ex)
                {
                    return(InternalServerError());
                }
            }
            return(Unauthorized());
        }
Пример #13
0
        public ViewResult Update()
        {
            var userId         = ApplicationContext.UserId;
            var schoolId       = ApplicationContext.SchoolId;
            var userInfoResult = UserService.Instance.GetUserInfoByUserId(new GetObjectByIdArgs()
            {
                OId      = userId,
                SchoolId = ApplicationContext.SchoolId
            });
            var userInfo = new UserLite();

            if (userInfoResult.Code == 200)
            {
                userInfo = userInfoResult.Items.FirstOrDefault();
            }

            return(View(userInfo));
        }
Пример #14
0
 /// <summary>
 /// Create user
 /// </summary>
 /// <param name="UserLite"></param>
 public void Create(UserLite UserLite)
 {
     _connection.Insert(UserLite);
     _connection.Commit();
 }
 private static void AssertMessageCreatedBy(UserLite user)
 {
     Context.Transport.TpQueue.GetMessages <CreateMessageCommand>().Count().Should(Be.EqualTo(1));
     Context.CreatedMessageDtos.Single().FromID.Should(Be.EqualTo(user.Id), "Message was created on behalf of wrong user");
 }
Пример #16
0
 /// <summary>
 /// Update User
 /// </summary>
 /// <param name="UserLite"></param>
 public void Update(UserLite UserLite)
 {
     _connection.Update(UserLite);
     _connection.Commit();
 }
Пример #17
0
 public ChatMessagePage(UserLite receiver)
 {
     InitializeComponent();
     BindingContext = viewModel = new ChatMessageViewModel(receiver);
 }
        public void Handle(UserCreatedMessage message)
        {
            var user = UserLite.Create(message.Dto);

            AddToRepository(user);
        }
 public void Handle(RequesterCreatedMessage message)
 {
     AddToRepository(UserLite.Create(message.Dto));
 }
 private static void AddUserLite(UserLite userLite)
 {
     ObjectFactory.GetInstance <UserRepository>().Add(userLite);
 }
 public void Handle(RequesterUpdatedMessage message)
 {
     UpdateInRepository(UserLite.Create(message.Dto));
 }
 private void AddToRepository(UserLite userLite)
 {
     _userRepository.Add(userLite);
 }
Пример #23
0
 /// <summary>
 /// Delete user
 /// </summary>
 /// <param name="UserLite"></param>
 public void Delete(UserLite UserLite)
 {
     _connection.Delete(UserLite);
     _connection.Commit();
 }
 private void UpdateInRepository(UserLite userLiteUpdated)
 {
     _userRepository.Update(userLiteUpdated);
 }