Ejemplo n.º 1
0
        public HttpResponseMessage postnewfund(funds_table fund)
        {
            dbe.funds_table.Add(fund);
            dbe.SaveChanges();

            return(Request.CreateResponse(HttpStatusCode.Accepted, "accepted fund"));
        }
Ejemplo n.º 2
0
        public HttpResponseMessage registernewuser(user_table u)
        {
            dbe.user_table.Add(u);
            dbe.SaveChanges();

            return(Request.CreateResponse(HttpStatusCode.Accepted, "Signup Sucessfull"));
        }
Ejemplo n.º 3
0
        public async void CalculateNearbyUser(string latitude, string longitude, int issueId)
        {
            double latitude_    = Convert.ToDouble(latitude);
            double longitude_   = Convert.ToDouble(longitude);
            var    ICoardinates = new GeoCoordinate(latitude_, longitude_);
            //111 meters=0.001 degrees( of Latitude and Longitude)
            await Task.Run(() =>
            {
                foreach (var item in dbe.user_table.ToList())
                {
                    var UCoardinates = new GeoCoordinate(Convert.ToDouble(item.homelocatlati), Convert.ToDouble(item.homelocatlongi));
                    var distance     = ICoardinates.GetDistanceTo(UCoardinates);
                    if (distance < 100)
                    {
                        dbe.nearby_user_table.Add(new nearby_user_table {
                            issue_id = issueId, user_id = item.user_id, Isverified = 0
                        });
                        dbe.SaveChanges();
                    }
                }
            });

            PushNotificationController controller = new PushNotificationController()
            {
                Request       = new System.Net.Http.HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };

            controller.sendverificationnotification(issueId);
        }
        public HttpResponseMessage SaveToken([FromUri] string Token, [FromUri] int userId)
        {
            var oldToken = dbe.FCM_TOKEN.Where(x => x.UserID == userId).FirstOrDefault();

            //Deleting old Token
            if (oldToken != null)
            {
                dbe.FCM_TOKEN.Remove(oldToken);
                dbe.SaveChanges();
            }
            //Adding new token
            FCM_TOKEN token = new FCM_TOKEN();

            token.Token  = Token;
            token.UserID = userId;
            dbe.FCM_TOKEN.Add(token);
            dbe.SaveChanges();

            return(Request.CreateResponse(HttpStatusCode.Accepted, "token saved"));
        }
        public async Task <HttpResponseMessage> postnewissue(issue_table issue)
        {
            try
            {
                // Your code...
                // Could also be before try if you know the exception occurs in SaveChanges
                dbe.issue_table.Add(issue);

                dbe.SaveChanges();
                var originalSynchronizationContext = SynchronizationContext.Current;
                try
                {
                    SynchronizationContext.SetSynchronizationContext(null);
                    new NearbyUserController().findnearbyusers(issue.issue_id);
                }
                catch (Exception ex)
                {
                    StreamWriter sw = new StreamWriter("D:\\WORK\\abcerror.txt");
                    sw.WriteLine("EXCEPTION::" + ex.ToString());
                    sw.Close();
                }
                finally
                {
                    SynchronizationContext.SetSynchronizationContext(originalSynchronizationContext);
                }



                return(Request.CreateResponse(HttpStatusCode.Accepted, "Issue Posted Sucessfully"));
            }
            catch (DbEntityValidationException ex)
            {
                StreamWriter sw = new StreamWriter("D:\\WORK\\abcerror.txt");
                foreach (var eve in ex.EntityValidationErrors)
                {
                    sw.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                 eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        sw.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                     ve.PropertyName, ve.ErrorMessage);
                    }
                }
                sw.Close();
            }

            return(Request.CreateResponse(HttpStatusCode.NotAcceptable, "Issue posting error"));
        }
        public HttpResponseMessage changeusername(string name, string oldname, string password)
        {
            var record = dbe.Volunteer_table.Where(x => x.name == oldname && x.password == password).FirstOrDefault();

            if (record != null)
            {
                record.name = name;
                dbe.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.Accepted));
            }
            return(Request.CreateResponse(HttpStatusCode.NotAcceptable));
        }
        public HttpResponseMessage updateuserstatus(int userid)
        {
            var user = dbe.user_table.Where(x => x.user_id == userid).FirstOrDefault();

            if (user != null)
            {
                if (user.Status == "active")
                {
                    user.Status = "blocked";
                    dbe.SaveChanges();
                }
                else if (user.Status == "blocked")
                {
                    user.Status = "active";
                    dbe.SaveChanges();
                }

                return(Request.CreateResponse(HttpStatusCode.Accepted, ""));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, ""));
        }