コード例 #1
0
        public IHttpActionResult Create([FromBody] AddActivity activity)
        {
            AmigoWallEntities db = new AmigoWallEntities();
            var user = db.AspNetUsers.Single(u => u.UserName == User.Identity.Name);
            C_Activity ac = new C_Activity
            {
                id = Guid.NewGuid().ToString(),
                ActivityPost = activity.ActivityPost,
                ActivityName = activity.ActivityName,
                ActivityStart = activity.ActivityStart,
                ActivityEnd = activity.ActivityEnd,
                Location = activity.Location,
                LocationProxy = activity.LocationProxy == "" ? null : activity.LocationProxy,
                Album = activity.Album == "" ? null : activity.Album,
                pv = 0,
                IsDelete = false,
                IsPublish = false,
                pvpy = 0,
                Creator = user.Id,
                AddTime = UtilityHelper.getNow()

            };
            db.C_Activity.Add(ac);
            db.SaveChanges();

            return Json(new
            {
                Code = 10000,
                Detail = 1
            });
        }
コード例 #2
0
        public IHttpActionResult AddNewAlbum([FromBody] AddNewAlbumModel model)
        {
            AmigoWallEntities db = new AmigoWallEntities();
            var album = new tb_Album
            {
                AddDate = UtilityHelper.getNow(),
                AlbumIcon = model.ImageUrl,
                AlbumName = model.AlbumName,
                Organizer = db.AspNetUsers.Single(u => u.UserName == User.Identity.Name).Id,
                UserId = db.AspNetUsers.Single(u => u.UserName == User.Identity.Name).Id,
                id = Guid.NewGuid().ToString()
            };
            db.tb_Album.Add(album);
            db.SaveChanges();
            return Json(new
            {
                Code = 10000,
                Detail = new
                {

                }

            });
        }
コード例 #3
0
 public static void Log(int type,string message,string source)
 {
     var log = new cm_Log
     {
         AddDate = getNow(),
         id = Guid.NewGuid().ToString(),
         Message = message,
         Source = source,
         Type = type
     };
     AmigoWallEntities db = new AmigoWallEntities();
     db.cm_Log.Add(log);
     db.SaveChanges();
 }
コード例 #4
0
        public IHttpActionResult AddNewLocation([FromBody]  AddNewLocationModel model)
        {
            AmigoWallEntities db = new AmigoWallEntities();
            var location = new tb_Location
            {
                Id = Guid.NewGuid().ToString(),
                AddTime = UtilityHelper.getNow(),
                Latitude = model.latitude,
                longitude = model.longtitude,
                LocationName = model.LocationName,
                FullAddress = model.AddressName,
                Status = 0,
                UserId = db.AspNetUsers.Single(u => u.UserName == User.Identity.Name).Id
            };
            db.tb_Location.Add(location);
            db.SaveChanges();
            return Json(new
            {
                Code = 10000,
                Detail = new
                {

                }

            });
        }
コード例 #5
0
        public IHttpActionResult ModifyLocation([FromBody] ModeifyLocation model)
        {
            AmigoWallEntities db = new AmigoWallEntities();
            var obj = db.tb_Location.Single(u => u.Id == model.LocationId);
            obj.LocationName = model.LocationName;
            obj.FullAddress = model.AddressName;
            obj.Latitude = model.latitude;
            obj.longitude = model.longtitude;
            db.SaveChanges();

            return Json(new
            {
                Code = 10000,
                Detail = new
                {
                    // data = list
                }

            });
        }
コード例 #6
0
        public IHttpActionResult saveAlbumById([FromBody] AlbumModel model)
        {
            AmigoWallEntities db = new AmigoWallEntities();
            var Org = db.AspNetUsers.Single(u => u.UserName == User.Identity.Name);
            var OrgId = Org.Id;
            var album = db.tb_Album.Single(u => u.id == model.AlbumId);

            album.AlbumName = model.AlbumName;
            db.SaveChanges();
            var list = db.tb_Album.Where(u => !u.IsDelete && u.Organizer == OrgId).Select(u => new
            {
                AlbumId = u.id,
                AlbumName = u.AlbumName,
                AlbumIcon = u.AlbumIcon
            });
            return Json(new
            {
                Code = 10000,
                Detail = new
                {
                    data = list
                }
            });
        }
コード例 #7
0
        public IHttpActionResult changeUserPortrait([FromBody] changeUserPortrait model)
        {
            AmigoWallEntities db = new AmigoWallEntities();
            var obj = db.AspNetUsers.Include("AspNetUsers_Person").Include("AspNetUsers_Org").Single(u => u.UserName == User.Identity.Name);
            obj.Portrait = model.imageurl;
            db.SaveChanges();
            return Json(new
            {
                Code = 10000,
                Detail = new
                {

                }

            });
        }
コード例 #8
0
        public async Task<IHttpActionResult> OrgRegister([FromBody] registerObj model)
        {
            AmigoWallEntities db = new AmigoWallEntities();
            if (!HDYHelper.VerifyMobileCode(model.Mobile, model.Code))
            {
                return Json(new { Code = 1, Message = "验证码错误或已经失效" });
            }

            //可以注册,是自己的号码
            if (db.AspNetUsers_Org.Any(u => u.PhoneNo == model.Mobile))
            {
                return Json(new { Code = 1, Message = "该手机号码已经被注册" });
            }
            //开始创建新账户
            //注册id
            string id = Guid.NewGuid().ToString();
            var user = new ApplicationUser()
            {
                Id = id,
                UserName = "******" + Guid.NewGuid().ToString(),
                NickName = "o" + model.Mobile,
                IsOrganization = true,
                RegisterTime = UtilityHelper.getNow(),
                IsActive = true,
                EmailConfirmed = false,
                //  Email = para.Email,
                PhoneNumberConfirmed = false,
                AccessFailedCount = 0,
                LockoutEnabled = true,
                Sex = 2,  //表示没有性别认定
                Portrait = "http://hdy.awblob.com/portrait/orgdefault.jpg",
                LoginPassword = model.Password
            };
            IdentityResult result = await Request.GetOwinContext().GetUserManager<ApplicationUserManager>().CreateAsync(user);
            if (!result.Succeeded)
            {
                return Json(new { Code = 1, Message = "注册不成功" });
            }
            else
            {
                //注册成功
                HuoDongYou.Models.Entities.AspNetUsers_Org org = new Models.Entities.AspNetUsers_Org
                {
                    id = id,
                    PhoneNo = model.Mobile
                };

                C_Follow follow = new C_Follow
                {
                    FromId = id,
                    ToId = id,
                    AddDate = UtilityHelper.getNow()
                };
                //C_Follow follow2 = new C_Follow
                //{
                //    FromId = id,
                //    ToId = "34d6c28a-6c9d-474c-90a9-4ba66a52f010"
                //};
                db.C_Follow.Add(follow);
                //    db.C_Follow.Add(follow2);
                db.AspNetUsers_Org.Add(org);
                db.SaveChanges();
            }
            string grant_type = "password";
            string password = BlobString.PasswordString;
            ASCIIEncoding encoding = new ASCIIEncoding();
            string postData = "grant_type=" + grant_type;
            postData += ("&password="******"o" + model.Password);
            postData += "&username="******"http://newhuodongyou.chinacloudsites.cn/token");
            myRequest.Method = "POST";
            myRequest.ContentType = "application/x-www-form-urlencoded";
            myRequest.ContentLength = data.Length;
            Stream newStream = myRequest.GetRequestStream();

            // Send the data.
            newStream.Write(data, 0, data.Length);
            newStream.Close();

            // Get response
            HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
            StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.Default);
            string content = reader.ReadToEnd();
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            Dictionary<string, object> json = (Dictionary<string, object>)serializer.DeserializeObject(content);
            string username = json["userName"].ToString();
            var myuser = db.AspNetUsers_Org.Include("AspNetUsers").Single(u => u.AspNetUsers.UserName == username);
            return Json(new
            {
                Code = 10000,
                Detail = new
                {
                    token = json["access_token"].ToString(),
                    IsValid = true,
                    expired = json[".expires"].ToString(),
                    NickName = myuser.AspNetUsers.NickName,
                    UserName = myuser.AspNetUsers.UserName,
                    Portrait = myuser.AspNetUsers.Portrait
                }
            });
        }
コード例 #9
0
        public async Task<IHttpActionResult> Reset([FromBody] registerObj model)
        {
            AmigoWallEntities db = new AmigoWallEntities();


            if (HDYHelper.VerifyMobileCode(model.Mobile, model.Code))
            {
                return Json(new { Code = 1, Detail = "验证码错误或者已经失效" });
            }
            else
            {

                //可以注册,是自己的号码
                if (db.AspNetUsers_Org.Any(u => u.PhoneNo == model.Mobile))
                {
                    var obj = db.AspNetUsers_Org.Include("AspNetUsers").Single(u => u.PhoneNo == model.Mobile);
                    obj.AspNetUsers.LoginPassword = model.Password;
                    db.SaveChanges();
                    return Json(new
                    {
                        Code = 10000,
                        detail = 1
                    });
                }
                else
                {
                    return Json(new { Code = 10000, Detail = 2 });

                }
            }

        }
コード例 #10
0
        public IHttpActionResult sat(int number)
        {
            AmigoWallEntities db = new AmigoWallEntities();
            cm_Sat sat = new cm_Sat
            {
                id = Guid.NewGuid().ToString(),
                Adddate = DateTime.Now,
                number = number,
                UserName = User.Identity.Name
            };
            db.cm_Sat.Add(sat);
            db.SaveChanges();
            return Json(new
            {
                r = true
            });

        }
コード例 #11
0
        public string MobielWebLogin()
        {
            string id = Guid.NewGuid().ToString();
            cm_ConfirmMobileLogin login = new cm_ConfirmMobileLogin
            {
                id = id,
                AddDate = UtilityHelper.getNow(),
                IsConfirmed = false,
                UserName = User.Identity.Name,

            };
            HuoDongYou.Models.Entities.AmigoWallEntities db = new HuoDongYou.Models.Entities.AmigoWallEntities();
            db.cm_ConfirmMobileLogin.Add(login);
            db.SaveChanges();
            return id;
        }