public async Task <IActionResult> PostFindByTIN([FromBody] FindUsers model) { if (model.TIN == null) { return(NotFound("Email not found")); } string Query = " [GetTaxAppByTIN] {0}"; object[] Parameters = { model.TIN }; try { var Result = await Repo.TaxApp_Repository.ExecuteQuery(Query, Parameters); if (Result.Count() > 0) { return(Ok(Result)); } else { return(BadRequest()); } } catch (Exception Ex) { return(BadRequest(Ex)); } }
public async Task <IActionResult> PostFindUserName([FromBody] FindUsers model) { if (model.UserName == null) { return(NotFound("empty")); } try { // Admin User = await IUnitOfWork.Admin_Repository.GetById(id); string Query = "[GetTaxRegByUserName] {0}"; object[] Para = { model.UserName }; var User = await IUnitOfWork.TaxReg_Repository.ExecuteQuery(Query, Para); if (User.Count() < 1) { return(NotFound("User Not Found")); } else { return(Ok(User)); } } catch (Exception) { return(NotFound("error")); } }
public object Any(FindUsers request) { Stopwatch s = new Stopwatch(); s.Start(); var result = Search(request); s.Stop(); result.Duration = s.ElapsedMilliseconds; return(result); }
PaginatedResult <User> Search(FindUsers request) { PaginatedResult <User> result = new PaginatedResult <User>() { Data = new List <User>() }; RavenQueryStatistics statsRef = new RavenQueryStatistics(); var results = DocumentSession.Query <Users_Smart_Search.Result, Users_Smart_Search>() .Statistics(out statsRef) .Search(x => x.Content, $"{request.Qry}*", escapeQueryOptions: EscapeQueryOptions.AllowPostfixWildcard) .Skip(request.CurrentPage * request.PageSize) .Take(request.PageSize) .ProjectFromIndexFieldsInto <Users_Smart_Search.Projection>(); result.Data = ConvertResultsToUsersViewModel(results.ToList()); result.TotalItems = statsRef.TotalResults; result.TotalPages = result.TotalItems / request.PageSize; if ((result.TotalItems % request.PageSize) > 0) { result.TotalPages += 1; } result.PageSize = request.PageSize; result.CurrentPage = request.CurrentPage; if (CurrentPageIsOverflown(result)) { return(Search(new FindUsers() { Qry = request.Qry, CurrentPage = 0, PageSize = request.PageSize })); } return(result); }
public ActionResult Find_Users() { string username = Request.QueryString["user"].ToString(); string pagesize = Request.QueryString["p"].ToString(); string catorgray = Request.QueryString["cator"].ToString(); string province = Request.QueryString["prov"].ToString(); string city = Request.QueryString["cit"].ToString(); string area = Request.QueryString["ar"].ToString(); string industry = Request.QueryString["indus"].ToString(); long pgCount = 0; List<FindUsers> us = new List<FindUsers>(); IMongoQuery q = null; if (!string.IsNullOrEmpty(province)) { q = q.And(MongoDB.Driver.Builders.Query.EQ("所属地域.省份", province)); if (city != "不限" && !string.IsNullOrEmpty(city) && !string.IsNullOrEmpty(area) && area != "不限") { q = q.And(MongoDB.Driver.Builders.Query.EQ("所属地域.城市", city)); q = q.And(MongoDB.Driver.Builders.Query.EQ("所属地域.区县", area)); } } if (catorgray == "单位用户") { if (!string.IsNullOrWhiteSpace(username)) { q = q.And(Query.EQ("单位信息.单位代号", new BsonRegularExpression(string.Format("/{0}/i", username)))); q = q.And(Query.EQ("单位信息.单位名称", new BsonRegularExpression(string.Format("/{0}/i", username)))); } long sum = 用户管理.计数用户<单位用户>(0, 0, q); pgCount = sum / 12; if (sum % 12 > 0) { pgCount++; } if (string.IsNullOrEmpty(pagesize)) { pagesize = "1"; } IEnumerable<单位用户> Department = 用户管理.查询用户<单位用户>((int.Parse(pagesize) - 1) * 12, 12, q); if (Department != null) { for (int i = 0; i < Department.Count(); i++) { FindUsers u = new FindUsers(); if (string.IsNullOrWhiteSpace(Department.ElementAt(i).单位信息.单位代号)) { u.name = Department.ElementAt(i).单位信息.单位名称; } else { u.name = Department.ElementAt(i).单位信息.单位代号; } u.loginName = Department.ElementAt(i).登录信息.登录名; us.Add(u); } } } else if (catorgray == "专家") { if (!string.IsNullOrWhiteSpace(username)) { q = q.And(Query.EQ("身份信息.姓名", new BsonRegularExpression(string.Format("/{0}/i", username)))); } long sum = 用户管理.计数用户<专家>(0, 0, q); pgCount = sum / 12; if (sum % 12 > 0) { pgCount++; } if (string.IsNullOrEmpty(pagesize)) { pagesize = "1"; } IEnumerable<专家> Department = 用户管理.查询用户<专家>((int.Parse(pagesize) - 1) * 12, 12, q); if (Department != null) { for (int i = 0; i < Department.Count(); i++) { FindUsers u = new FindUsers(); u.name = Department.ElementAt(i).身份信息.姓名; u.loginName = Department.ElementAt(i).登录信息.登录名; us.Add(u); } } } else if (catorgray == "供应商") { if (!string.IsNullOrEmpty(industry)) { q = q.And(Query.EQ("企业基本信息.所属行业", industry)); } if (!string.IsNullOrWhiteSpace(username)) { q = q.And(Query.EQ("企业基本信息.企业名称", new BsonRegularExpression(string.Format("/{0}/i", username)))); //q.And(Query.EQ("企业基本信息.企业名称",username)); } long sum = 用户管理.计数用户<供应商>(0, 0, q); pgCount = sum / 12; if (sum % 12 > 0) { pgCount++; } if (string.IsNullOrEmpty(pagesize)) { pagesize = "1"; } IEnumerable<供应商> Department = 用户管理.查询用户<供应商>((int.Parse(pagesize) - 1) * 12, 12, q); if (Department != null) { for (int i = 0; i < Department.Count(); i++) { FindUsers u = new FindUsers(); u.name = Department.ElementAt(i).企业基本信息.企业名称; u.loginName = Department.ElementAt(i).登录信息.登录名; us.Add(u); } } } JsonResult json = new JsonResult() { Data = new { name = us, pageCount = pgCount } }; return Json(json, JsonRequestBehavior.AllowGet); }
public async Task <ActionResult> addnewIncident(IncidentRequest incidentRequest) { string incidentId = Guid.NewGuid().ToString(); Incident incident = new Incident { Id = incidentId, UserAccountId = incidentRequest.UserAccountId, IncidentTypeId = incidentRequest.IncidentTypeId, IncidentPic = incidentRequest.IncidentPic, Address = incidentRequest.Address, AddressLine = incidentRequest.AddressLine, CoordinateX = incidentRequest.CoordinateX, CoordinateY = incidentRequest.CoordinateY, CustomerComments = incidentRequest.CustomerComments, Status = incidentRequest.Status, Deleted = false, CreatedAt = DateTime.Now }; appDbContex.Incidents.Add(incident); await appDbContex.SaveChangesAsync(); List <ApplicationUser> usersToNotify = new List <ApplicationUser>(); FindUsers findUsers = new FindUsers(appDbContex, userManager); usersToNotify = findUsers.FindUsersToNotifybyCoordinateXY(incidentRequest.CoordinateX, incidentRequest.CoordinateY, incidentRequest.IncidentTypeId); PushNotificationLogic pushNotificationLogic = new PushNotificationLogic(); // string[] androidDeviceTocken; List <string> androidDeviceTocken = new List <string>(); SendSms sendsms = new SendSms(); var incidenttypeName = appDbContex.IncidentTypes.Where(a => a.Id == incidentRequest.IncidentTypeId).FirstOrDefault(); string contactNumber = string.Empty; string location = "http://maps.google.com/?q=" + incidentRequest.CoordinateX + "," + incidentRequest.CoordinateY + ""; string notificationMessage = string.Empty; foreach (var user in usersToNotify) { //if (user.Source == "Android") //{ // androidDeviceTocken.Add(user.PushTokenId); //} if (user.EmergencyContactNo != null) { //Notification to Emergency Contact contactNumber = user.InternationalPrefix.ToString() + user.PhoneNumber.ToString(); notificationMessage = "Here is the " + incidenttypeName.Name + " incident happen... please click here " + location; // sendsms.SendTextSms(notificationMessage, contactNumber); } else { //Notification to Application Users contactNumber = user.InternationalPrefix.ToString() + user.PhoneNumber.ToString(); notificationMessage = "Here is the " + incidenttypeName.Name + " incident happen... please click here " + location; // sendsms.SendTextSms(notificationMessage, contactNumber); } NotifiedUser notifiedUser = new NotifiedUser { Id = Guid.NewGuid().ToString(), IncidentId = incidentId, UserId = user.Id, CreatedAt = DateTime.Now }; appDbContex.NotifiedUsers.Add(notifiedUser); await appDbContex.SaveChangesAsync(); IncidentUserMessage incidentUserMessage = new IncidentUserMessage { Id = Guid.NewGuid().ToString(), IncidentId = incidentId, UserId = user.Id, Status = incidentRequest.Status, StatusMessage = notificationMessage, CreatedAt = DateTime.Now }; appDbContex.IncidentUserMessages.Add(incidentUserMessage); await appDbContex.SaveChangesAsync(); } try { // androidDeviceTocken = null; // androidDeviceTocken.Add("f4e9GJxSvYA:APA91bGkImijMYelYhFCqFTE6qDzEfzeEdM6H3Q1XwxxCDvYWZGdyviRGtPSdTcyeXy4787JPwfb04pFNWo5dXIc420EVZEQ15UtHqTCAn8kk8zdAJ8pgRLLMNbKkJ1dfR5ABMoMJd71"); // androidDeviceTocken.Add("ccSVgC04gaM:APA91bGt8rDg-1CyG5N9pxW5aXWs9x4jpf6rXYXRu0usnaiMzgfosr5Guv89iJbiHBvUcOYkGf2RIJBx_-jtK_76bZwk__d3Xn94TSXLmaC8rs9GEnIvX5AOldPXqp1EiUvIrt1zfQcr"); androidDeviceTocken.Add("dndndqNSHbs:APA91bFrO7Au5DvoYIgFaWY1S7PLAzzcwZ9EcuwjKvqFBdM-733zwDKCWnT5JZ9FcSVsUb1JwYUWCElXmFpgd6BXkTcUn9ejhvrwvB0eIC9Mpn4komqfT_APS2TaX9ZtZ_a_TbjfFswH"); if (androidDeviceTocken != null) { // Myobject myobj = new Myobject // { // Name = "Bhavin", // City = "vapi" // }; var myobj = new { Name = "Bhavin", City = "Vapi" }; await pushNotificationLogic.SendPushNotification(androidDeviceTocken, "SecureAfrica", notificationMessage, myobj); } } catch (Exception ex) { } await _hubContext.Clients.All.BroadcastMessage("success", "this is our msg"); return(Ok(new { Message = "Incident added successfully !" })); }
public async Task <ActionResult> updateIncidentStatus(UpdateIncidentStatusRequest updateIncidentStatusRequest) { Incident incident = appDbContex.Incidents.Where(a => a.Id == updateIncidentStatusRequest.Id).FirstOrDefault(); if (incident != null) { if (incident.EmergencyAccountId == null || incident.EmergencyAccountId == updateIncidentStatusRequest.EmergencyAccountId) { incident.EmergencyAccountId = updateIncidentStatusRequest.EmergencyAccountId; incident.Status = updateIncidentStatusRequest.Status; incident.UpdatedAt = DateTime.Now; await appDbContex.SaveChangesAsync(); List <ApplicationUser> usersToNotify = new List <ApplicationUser>(); FindUsers findUsers = new FindUsers(appDbContex, userManager); usersToNotify = findUsers.FindUsersToNotifybyCoordinateXY(incident.CoordinateX, incident.CoordinateY, incident.IncidentTypeId); SendSms sendsms = new SendSms(); string contactNumber = string.Empty; var incidenttypeName = appDbContex.IncidentTypes.Where(a => a.Id == incident.IncidentTypeId).FirstOrDefault(); foreach (var user in usersToNotify) { NotifiedUser notifiedUser = appDbContex.NotifiedUsers.Where(a => a.IncidentId == updateIncidentStatusRequest.Id && a.UserId == user.Id).FirstOrDefault(); if (notifiedUser == null) { NotifiedUser addNotifiedUser = new NotifiedUser { Id = Guid.NewGuid().ToString(), IncidentId = updateIncidentStatusRequest.Id, UserId = user.Id, CreatedAt = DateTime.Now }; appDbContex.NotifiedUsers.Add(addNotifiedUser); await appDbContex.SaveChangesAsync(); } } List <NotifiedUser> lstnotifiedUsers = appDbContex.NotifiedUsers.Where(a => a.IncidentId == updateIncidentStatusRequest.Id).ToList(); List <ApplicationUser> usersToNotify1 = new List <ApplicationUser>(); foreach (var user in lstnotifiedUsers) { ApplicationUser appUser = userManager.Users.Where(a => a.Id == user.UserId).FirstOrDefault(); if (appUser != null) { usersToNotify1.Add(appUser); } } string notificationMessage = string.Empty; string location = "http://maps.google.com/?q=" + incident.CoordinateX + "," + incident.CoordinateY + ""; foreach (var user in usersToNotify1) { if (user.EmergencyContactNo != null) { //Notification to Emergency Contact contactNumber = user.InternationalPrefix.ToString() + user.PhoneNumber.ToString(); notificationMessage = "Here is the " + incidenttypeName.Name + " incident happen... please click here " + location; sendsms.SendTextSms(notificationMessage, contactNumber); } else { //Notification to User contactNumber = user.InternationalPrefix.ToString() + user.PhoneNumber.ToString(); notificationMessage = "Here is the " + incidenttypeName.Name + " incident happen... please click here " + location; sendsms.SendTextSms(notificationMessage, contactNumber); } IncidentUserMessage incidentUserMessage = new IncidentUserMessage { Id = Guid.NewGuid().ToString(), IncidentId = updateIncidentStatusRequest.Id, UserId = user.Id, Status = updateIncidentStatusRequest.Status, StatusMessage = notificationMessage, CreatedAt = DateTime.Now }; appDbContex.IncidentUserMessages.Add(incidentUserMessage); await appDbContex.SaveChangesAsync(); } } return(Ok(new { Message = "Incident Updated successfully !" })); } return(BadRequest(new { Message = "Incident Not Found !" })); }