public ResponseModel Mapcategory([FromBody] CustomUserModel customUserModel) { ResponseModel objResponseModel = new ResponseModel(); int statusCode = 0; string statusMessage = ""; try { string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token)); UserCaller userCaller = new UserCaller(); customUserModel.CreatedBy = authenticate.UserMasterID; customUserModel.TenantID = authenticate.TenantId; int Result = userCaller.Mappedcategory(new UserServices(Cache, Db), customUserModel); statusCode = Result == 0 ? (int)EnumMaster.StatusCode.RecordNotFound : (int)EnumMaster.StatusCode.Success; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = Result; } catch (Exception) { throw; } return(objResponseModel); }
public void UserControllerTestInitialize() { _userDetailRepository = new Mock <IUserDetailRepository>(); _testUser1 = new UserDetails { Id = Guid.NewGuid(), UserName = "******", Password = "******".HashPassword(), UserType = 1 }; _testUserList = new List <UserDetails>(); _testUserList.Add(_testUser1); _testCustomeUserModel = new CustomUserModel { UserName = "******", UserType = 1 }; _testUserforInsert = new CustomeUserDetailsModelForInsert { UserName = "******", Password = "******", UserType = 2 }; _testUserforDuplicateInsert = new CustomeUserDetailsModelForInsert { UserName = "******", Password = "******", UserType = 2 }; }
protected override IEnumerable <ChatViewModel> GetSearchResult(string key) { if (string.IsNullOrEmpty(key) || key.Length < 11) { return(null); } var result = SDKClient.SDKClient.Instance.GetUserInfoByMobile(key); if (result.success) { if (result.entity != null) { IChat chat = new UserModel() { ID = result.entity.userId, DisplayName = result.entity.mobile, HeadImg = ImagePathHelper.DefaultUserHead, }; chat.HeadImg = result.entity.photo ?? ImagePathHelper.DefaultUserHead; ChatModel chatModel = AppData.Current.GetChatViewModel(chat); ChatViewModel chatVM = new ChatViewModel(chatModel); CustomUserModel customUserModel = new CustomUserModel() { AppType = result.entity.appType, ShopBackUrl = result.entity.shopBackUrl, ShopId = result.entity.shopId, ShopName = result.entity.shopName ?? result.entity.mobile, Mobile = result.entity.mobile }; chatVM.CustomUserModel = customUserModel; chatVM.SessionId = result.entity.sessionId; if (result.entity.sessionType == 0) { chatVM.StartOrStopSession(false); chatVM.sessionType = 0; } else if (result.entity.sessionType == 1) { chatVM.StartOrStopSession(true); chatVM.SessionId = result.entity.sessionId; chatVM.sessionType = 1; } else { chatVM.sessionType = 2;//别人的会话 } ObservableCollection <ChatViewModel> list = new ObservableCollection <ChatViewModel>(); App.Current.Dispatcher.Invoke(new Action(() => { list.Add(chatVM); })); return(list); } } return(this.Items.Where(info => !string.IsNullOrEmpty((info.Model as ChatModel).Chat.DisplayName) && (info.Model as ChatModel).Chat.DisplayName.Equals(key))); }
public ActionResult LogIn(LogInModel UserLogin) { if (ModelState.IsValid) { UserLogin.Password = EncryptDecrypt.Encrypt(UserLogin.Password); UserModel UserData = objManageUser.LogIn(UserLogin); if (UserData != null) { Session.Abandon(); CustomUserModel CustomUser = new CustomUserModel(); var serializer = new JavaScriptSerializer(); CustomUser.UserName = UserData.Email; CustomUser.ID = UserData.ID; CustomUser.FullName = UserData.FirstName + " " + UserData.LastName; if (UserData.TravelUserRoleMappings[0].RoleID != null) { CustomUser.RoleId = UserData.TravelUserRoleMappings[0].RoleID; CustomUser.RoleName = UserData.TravelUserRoleMappings[0].TravelRole.Name; } System.Web.HttpContext.Current.Items.Add("User", CustomUser); string userData = serializer.Serialize(CustomUser); FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket( 1, CustomUser.UserName, DateTime.Now, DateTime.Now.AddMinutes(10080), true, userData); string encTicket = FormsAuthentication.Encrypt(authTicket); HttpCookie faCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket); Response.Cookies.Add(faCookie); ///Not in use for now but will be used in api for validating/passing token TokenData tokenData = JsonConvert.DeserializeObject <TokenData>(GetAPIToken(UserData.Email, UserData.Password)); CustomUser.access_token = tokenData.access_token; CustomUser.token_type = tokenData.token_type; CustomUser.expires_in = tokenData.expires_in; //return RedirectToAction("profile", "user"); return(RedirectToAction("dashboard", "dashboard")); } else { ViewBag.Message = String.Format("Invalid Email or Password. Please try again"); return(View(UserLogin)); } } else { ModelState.AddModelError(string.Empty, "Data is not valid"); return(View(UserLogin)); } }
private async void LoadCustomServiceHistoryChats() { await SDKClient.SDKClient.Instance.GetCSRoomlist().ContinueWith(t => { var chats = t.Result; foreach (var item in chats) { IChat chat = AppData.Current.GetUserModel(item.userId); chat.DisplayName = item.shopName; chat.HeadImg = item.photo ?? ImagePathHelper.DefaultUserHead; ChatViewModel chatVM = this.Items.FirstOrDefault(info => info.ID == chat.ID); if (chatVM == null) { var last = new MessageModel() { Sender = chat, }; ChatModel model = AppData.Current.GetChatViewModel(chat); chatVM = new ChatViewModel(model, last); CustomUserModel customUserModel = new CustomUserModel() { AppType = item.appType, ShopBackUrl = item.shopBackUrl, ShopId = item.shopId, ShopName = item.shopName ?? item.mobile, Mobile = item.mobile }; chatVM.CustomUserModel = customUserModel; chatVM.SessionId = item.sessionId; if (item.sessionType == 0) { chatVM.StartOrStopSession(false); chatVM.sessionType = 0; } else if (item.sessionType == 1) { chatVM.StartOrStopSession(true); chatVM.SessionId = item.sessionId; chatVM.sessionType = 1; } else { chatVM.sessionType = 2;//别人的会话 } Items.Add(chatVM); } } }, View.UItaskScheduler); }
public CustomUserModel CurrentUserDetail() { FormsAuthenticationTicket retVal = null; HttpCookie curCookie = HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName]; if (curCookie != null && !String.IsNullOrWhiteSpace(curCookie.Value)) { retVal = FormsAuthentication.Decrypt(curCookie.Value); var jsonInput = retVal.UserData; CustomUserModel user = Newtonsoft.Json.JsonConvert.DeserializeObject <CustomUserModel>(jsonInput); return(user); } else { return(null); } }
public IHttpActionResult RegisterUser([FromBody] CustomUserModel userDetails) { try { var context = new DataModel(); userDetail tempDetails = new userDetail(); tempDetails.Age = userDetails.age; tempDetails.Fname = userDetails.firstName; tempDetails.Lname = userDetails.lastName; context.userDetails.Add(tempDetails); context.SaveChanges(); return(Ok()); } catch (Exception ex) { throw; } }
/// <summary> /// User Mapped category /// </summary> /// <param name="CustomUserModel"></param> public int Mappedcategory(CustomUserModel customUserModel) { int success = 0; try { conn.Open(); MySqlCommand cmd = new MySqlCommand("SP_InsertMappedUsercategory", conn); cmd.Connection = conn; cmd.Parameters.AddWithValue("@Brand_Ids", customUserModel.BrandIds); cmd.Parameters.AddWithValue("@Category_Ids", customUserModel.categoryIds); cmd.Parameters.AddWithValue("@SubCategory_Ids", customUserModel.subCategoryIds); cmd.Parameters.AddWithValue("@Issuetype_Ids", customUserModel.IssuetypeIds); cmd.Parameters.AddWithValue("@Role_ID", customUserModel.RoleID); cmd.Parameters.AddWithValue("@Is_CopyEscalation", customUserModel.IsCopyEscalation); cmd.Parameters.AddWithValue("@Is_AssignEscalation", customUserModel.IsAssignEscalation); cmd.Parameters.AddWithValue("@Is_Agent", customUserModel.IsAgent); cmd.Parameters.AddWithValue("@Is_Active", customUserModel.IsActive); cmd.Parameters.AddWithValue("@Created_By", customUserModel.CreatedBy); cmd.Parameters.AddWithValue("@User_ID", customUserModel.UserId); cmd.Parameters.AddWithValue("@Tenant_ID", customUserModel.TenantID); cmd.Parameters.AddWithValue("@EscalateAssignTo_Id", customUserModel.EscalateAssignToId); cmd.Parameters.AddWithValue("@Is_StoreUser", customUserModel.IsStoreUser); cmd.CommandType = CommandType.StoredProcedure; success = Convert.ToInt32(cmd.ExecuteNonQuery()); } catch (Exception) { throw; } finally { if (conn != null) { conn.Close(); } } return(success); }
/// <summary> /// User Mapped category /// </summary> /// <param name="CustomUserModel"></param> public int Mappedcategory(CustomUserModel customUserModel) { string password = CommonService.GeneratePassword(); CommonService commonService = new CommonService(); //string encryptedPassword = commonService.Encrypt(password); string encryptedPassword = SecurityService.Encrypt(password); int success = 0; try { conn = Db.Connection; MySqlCommand cmd = new MySqlCommand("SP_InsertMappedUsercategory", conn); cmd.Connection = conn; cmd.Parameters.AddWithValue("@Brand_Ids", customUserModel.BrandIds); cmd.Parameters.AddWithValue("@Category_Ids", customUserModel.categoryIds); cmd.Parameters.AddWithValue("@SubCategory_Ids", customUserModel.subCategoryIds); cmd.Parameters.AddWithValue("@Issuetype_Ids", customUserModel.IssuetypeIds); cmd.Parameters.AddWithValue("@Role_ID", customUserModel.RoleID); cmd.Parameters.AddWithValue("@Is_CopyEscalation", customUserModel.IsCopyEscalation); cmd.Parameters.AddWithValue("@Is_AssignEscalation", customUserModel.IsAssignEscalation); cmd.Parameters.AddWithValue("@Is_Agent", customUserModel.IsAgent); cmd.Parameters.AddWithValue("@Is_Active", customUserModel.IsActive); cmd.Parameters.AddWithValue("@Created_By", customUserModel.CreatedBy); cmd.Parameters.AddWithValue("@User_ID", customUserModel.UserId); cmd.Parameters.AddWithValue("@Tenant_ID", customUserModel.TenantID); cmd.Parameters.AddWithValue("@EscalateAssignTo_Id", customUserModel.EscalateAssignToId); cmd.Parameters.AddWithValue("@Is_StoreUser", customUserModel.IsStoreUser); cmd.Parameters.AddWithValue("@Encrypted_Password", encryptedPassword); cmd.CommandType = CommandType.StoredProcedure; success = Convert.ToInt32(cmd.ExecuteNonQuery()); } catch (Exception ex) { throw ex; } return(success); }
private List <TravelNotificationModel> GetNotificationData(string Status, string criteria, string fromDate, string toDate, string isActive) { List <TravelNotificationModel> lstNotificationList = new List <TravelNotificationModel>(); CustomUserModel user = CurrentUserDetail(); var notificationlist = objmanageCommon.GetNotificationList(user.ID, Status); if (notificationlist.StatusCode == HttpStatusCode.OK) { IEnumerable <TravelNotificationModel> data = JsonConvert.DeserializeObject <List <TravelNotificationModel> >(notificationlist.Content.ReadAsStringAsync().Result); //if (!String.IsNullOrEmpty(lastStatus)) //{ // int TravelLastSatus = Convert.ToInt32(lastStatus); // data = data.Where(x => x.LastStatus == TravelLastSatus).ToList(); //} if (isActive == "true") { data = data.Where(x => x.Status == true); } if (!String.IsNullOrEmpty(fromDate) && !String.IsNullOrEmpty(toDate)) { data = data.Where(x => x.NotificationDate >= Convert.ToDateTime(fromDate).Date).ToList(); ViewBag.fromdate = fromDate; ViewBag.todate = toDate; } foreach (var item in data) { if (item.TravelUser1 != null) { item.Name = item.TravelUser1.FirstName + " " + item.TravelUser1.LastName; } } lstNotificationList = data.ToList(); } return(lstNotificationList); }
public void SetSession(CustomServicePackage package) { if (package.data.type == 3) { return; } if (package.data.type == (int)SDKClient.SDKProperty.customOption.over)//结束 { ChatViewModel chatVM = this.Items.FirstOrDefault(info => info.ID == package.data.originTo.ToInt()); //没有条目 if (chatVM == null) { return; } else { if (((chatVM.Model as ChatModel).Chat as UserModel).HeadImg.Equals(ImagePathHelper.DefaultUserHead)) { ((chatVM.Model as ChatModel).Chat as UserModel).HeadImg = package.data.photo ?? ImagePathHelper.DefaultUserHead; } if (chatVM.Chat.LastMsg != null) { chatVM.Chat.LastMsg.SendTime = package.time.Value; } } chatVM.AddMessageTip("结束聊天"); chatVM.IsSessionEnd = true; chatVM.SessionId = string.Empty; chatVM.StartOrStopSession(false); chatVM.sessionType = 0; App.Current.Dispatcher.Invoke(() => { AppData.MainMV.ChatListVM.ResetSort(); }); } else if (package.data.type == (int)SDKClient.SDKProperty.customOption.conn)//接入 { ChatViewModel chatVM = this.Items.FirstOrDefault(info => info.ID == package.from.ToInt()); if (package.data.originTo == SDKClient.SDKClient.Instance.property.CurrentAccount.userID.ToString())//发送给我的接入 { //没有条目 if (chatVM == null) { IChat chat = new UserModel() { ID = package.from.ToInt(), DisplayName = package.data.shopName ?? package.data.mobile, HeadImg = package.data.photo ?? ImagePathHelper.DefaultUserHead }; ChatModel chatModel = AppData.Current.GetChatViewModel(chat); chatModel.LastMsg = new MessageModel() { SendTime = package.time.Value, }; chatVM = new ChatViewModel(chatModel); App.Current.Dispatcher.Invoke(new Action(() => { this.Items.Add(chatVM); })); } else { if (((chatVM.Model as ChatModel).Chat as UserModel).HeadImg.Equals(ImagePathHelper.DefaultUserHead)) { ((chatVM.Model as ChatModel).Chat as UserModel).HeadImg = package.data.photo ?? ImagePathHelper.DefaultUserHead; } if (chatVM.Chat.LastMsg != null) { chatVM.Chat.LastMsg.SendTime = package.time.Value; } } CustomUserModel customUserModel = new CustomUserModel() { AppType = package.data.appType, DeviceName = package.data.deviceName, DeviceType = package.data.deviceType, ShopBackUrl = package.data.shopBackUrl, ShopId = package.data.shopId, ShopName = package.data.shopName ?? package.data.mobile, //Mobile = package.data.mobile }; chatVM.CustomUserModel = customUserModel; chatVM.SessionId = package.data.sessionId; if (!string.IsNullOrEmpty(package.data.address)) { Task.Run(async() => { chatVM.CustomUserModel.Address = await SDKClient.SDKClient.Instance.GetAddressByIP(package.data.address).ConfigureAwait(false); }); } chatVM.IsDisplayStartSession = true; chatVM.sessionType = 1; //if((chatVM.Model as ChatModel).LastMsg?.Content!= "您好!欢迎光临满金店,请问有什么可以帮到您?") // chatVM.SendTextMsgToServer("您好!欢迎光临满金店,请问有什么可以帮到您?"); chatVM.StartOrStopSession(true); FlashIcon(chatVM, false); App.Current.Dispatcher.Invoke(() => { AppData.MainMV.ChatListVM.ResetSort(); }); } else { if (chatVM == null) { return; } else { if (((chatVM.Model as ChatModel).Chat as UserModel).HeadImg.Equals(ImagePathHelper.DefaultUserHead)) { ((chatVM.Model as ChatModel).Chat as UserModel).HeadImg = package.data.photo ?? ImagePathHelper.DefaultUserHead; } if (chatVM.Chat.LastMsg != null) { chatVM.Chat.LastMsg.SendTime = package.time.Value; } } CustomUserModel customUserModel = new CustomUserModel() { // Address = package.data.address, DeviceName = package.data.deviceName, DeviceType = package.data.deviceType, ShopBackUrl = package.data.shopBackUrl, //Mobile = package.data.mobile, ShopId = package.data.shopId, ShopName = package.data.shopName ?? package.data.mobile, }; chatVM.CustomUserModel = customUserModel; chatVM.SessionId = package.data.sessionId; if (!string.IsNullOrEmpty(package.data.address)) { Task.Run(async() => { chatVM.CustomUserModel.Address = await SDKClient.SDKClient.Instance.GetAddressByIP(package.data.address).ConfigureAwait(false); }); } chatVM.IsDisplayStartSession = false; chatVM.sessionType = 2; // chatVM.AddMessageTip("当前用户正在和其他客服进行沟通中", isSetLastMsg: false); chatVM.StartOrStopSession(false); App.Current.Dispatcher.Invoke(() => { AppData.MainMV.ChatListVM.ResetSort(); }); } } }
public int Mappedcategory(IUser User, CustomUserModel customUserModel) { _UserRepository = User; return(_UserRepository.Mappedcategory(customUserModel)); }