public void UpdateStatus(IDomainUserItem user) { foreach (var item in UserStorageInMemory) { if (user.Id == item.Key) { item.Value.Status = user.Status; item.Value.DomainStatus = user.DomainStatus; item.Value.weatherForecast = user.weatherForecast; item.Value.CountDays = user.CountDays; item.Value.Admin_MessageSend = user.Admin_MessageSend; item.Value.Admin_InputName = user.Admin_InputName; item.Value.Admin_InputNumber = user.Admin_InputNumber; item.Value.User_Reminder_CountDays = user.User_Reminder_CountDays; item.Value.User_Reminder_City = user.User_Reminder_City; item.Value.ReminderWeatherForecast = user.ReminderWeatherForecast; item.Value.Admin_Photo = user.Admin_Photo; item.Value.Admin_Caption = user.Admin_Caption; } } }
public void AddUser(IDomainUserItem user) { UserStorageInMemory.Add(user.Id, user); }
private void Receiver_MeesageReciver(object sender, MessageReceivedEventArgs e) { IDomainUserItem item = _storageInMemory.GetUser(e.ChatId); DomainUserItem userItem; if (item == null) { Telegram.Storage.Core.UserItem newUser = new Telegram.Storage.Core.UserItem() { ChatId = Convert.ToInt64(e.ChatId), DateOfRegistration = DateTimeOffset.Now, FirstName = e.FirstName, Id = Guid.NewGuid(), Message = e.Message, Status = StatusEnum.User, //StatusEnum.User }; _storage.AddUser(newUser); userItem = new DomainUserItem() { ChatId = newUser.ChatId, DateOfRegistration = newUser.DateOfRegistration, FirstName = newUser.FirstName, Id = newUser.Id, Message = newUser.Message, Status = newUser.Status, //newUser.Status, DomainStatus = DomainStatusEnum.Admin_Greeteng_Notification, //DomainStatusEnum.User_Greeting }; _storageInMemory.AddUser(userItem); } else { DomainStatusEnum domainStatus = item.DomainStatus; if (item.DomainStatus.Equals(DomainStatusEnum.Null)) { if (item.Status.Equals(StatusEnum.Admin)) { domainStatus = DomainStatusEnum.Admin_Greeteng_Notification; } else if (item.Status.Equals(StatusEnum.User)) { domainStatus = DomainStatusEnum.User_Greeting; } } userItem = new DomainUserItem() { ChatId = item.ChatId, DateOfRegistration = item.DateOfRegistration, FirstName = item.FirstName, Id = item.Id, Message = e.Message, Status = item.Status, //ITEM.STATUS DomainStatus = domainStatus, //item.DomainStatus weatherForecast = item.weatherForecast, Admin_MessageSend = item.Admin_MessageSend, Admin_InputName = item.Admin_InputName, CountDays = item.CountDays, User_Reminder_CountDays = item.User_Reminder_CountDays, User_Reminder_City = item.User_Reminder_City, ReminderWeatherForecast = item.ReminderWeatherForecast, Admin_Photo = item.Admin_Photo, Photo = e.Photo, Caption = e.Caption, Admin_Caption = item.Admin_Caption }; } userPanel = new UserPanel(userItem, _sender, _reminder); panelAdmin = new PanelAdmin(userItem, _sender, _storage); if (userItem.Status.Equals(StatusEnum.User)) { userItem = userPanel.UserPanelMessage(_storageInMemory); } else if (userItem.Status.Equals(StatusEnum.Admin)) { userItem = panelAdmin.PanelAdminMessage(_storageInMemory); } else { _sender.SendMessage(userItem.ChatId, "Хмм... Что-то пошло не так.", null); } if (userItem != item) { _storageInMemory.UpdateStatus(userItem); } }