public IHttpActionResult AddDifferent([FromBody] JObject value)
        {
            int     uid            = (int)value["UserId"];
            decimal price          = (decimal)value["Price"];
            int     type           = (int)value["Type"];
            string  link           = value["Link"].ToString();
            int     estimateNumber = (int)value["EstimateNumber"];
            int     actualNumber   = (int)value["ActualNumber"];

            Different different = new Different
            {
                UserId         = uid,
                State          = 1,
                Type           = type,
                Price          = price,
                Link           = link,
                EstimateNumber = estimateNumber,
                ActualNumber   = actualNumber,
                AddTimes       = DateTime.Now
            };

            entities.Different.Add(different);
            int result = entities.SaveChanges();

            if (result > 0)
            {
                return(Ok(Respone.Success("提交成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
Example #2
0
        public IHttpActionResult AddKeyWordUpHomePag([FromBody] JObject value)
        {
            int     id        = (int)value["UserId"];
            int     countryId = (int)value["CountryId"];
            string  asin      = value["ASIN"].ToString();
            decimal price     = (decimal)value["Price"];
            string  keyWord   = value["KeyWord"].ToString();

            KeyWordUpHomePag key = new KeyWordUpHomePag
            {
                UserId    = id,
                ASIN      = asin,
                Price     = price,
                KeyWord   = keyWord,
                State     = 1,
                CountryId = countryId,
                SubTime   = DateTime.Now
            };

            entities.KeyWordUpHomePag.Add(key);
            int result = entities.SaveChanges();

            if (result > 0)
            {
                return(Ok(Respone.Success("提交成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
Example #3
0
        public IHttpActionResult DeleteBadEvaluate([FromBody] JObject value)
        {
            int     id     = (int)value["UserId"];
            string  review = value["Review"].ToString();
            decimal price  = (decimal)value["Price"];

            BadEvaluate bad = new BadEvaluate
            {
                ReviewLink = review,
                State      = 1,             //待确认
                Price      = price,
                SubTime    = DateTime.Now,
                UserId     = id
            };

            entities.BadEvaluate.Add(bad);
            int result = entities.SaveChanges();

            if (result > 0)
            {
                return(Ok(Respone.Success("上传成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
        public IHttpActionResult AddSubmenu([FromBody] JObject value)
        {
            int          result      = 0;
            int          modularId   = (int)value["ModularId"];
            string       submenuName = value["SubmenuName"].ToString();
            decimal      price       = (decimal)value["Price"];
            string       remark      = value["Remark"].ToString();
            NavBySubmeun submenu     = new NavBySubmeun
            {
                ModularId   = modularId,
                SubmenuName = submenuName,
                Price       = price,
                Remark      = remark,
                State       = 1
            };

            entities.NavBySubmeun.Add(submenu);
            result = entities.SaveChanges();
            if (result > 0)
            {
                return(Ok(Respone.Success("添加成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
        public IHttpActionResult ChangeSubmenu([FromBody] JObject value)
        {
            int     result      = 0;
            int     id          = (int)value["Id"];
            string  submenuName = value["SubmenuName"].ToString();
            decimal price       = (decimal)value["Price"];
            string  remark      = value["Remark"].ToString();
            int     state       = (int)value["State"];

            var query = entities.NavBySubmeun.Where(e => e.Id == id).FirstOrDefault();

            if (query != null)
            {
                query.SubmenuName = submenuName;
                query.Price       = price;
                query.Remark      = remark;
                query.State       = state;
                DbEntityEntry entry = entities.Entry(query);
                entry.State = System.Data.Entity.EntityState.Modified;
                result      = entities.SaveChanges();
            }
            if (result > 0)
            {
                return(Ok(Respone.Success("修改成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
Example #6
0
        public IHttpActionResult ChangeDrawMoenyState([FromBody] JObject value)
        {
            int result = 0;
            int id     = (int)value["Id"];
            int state  = (int)value["State"];
            var query  = entities.DrawMoney.Where(d => d.Id == id).FirstOrDefault();

            if (query != null && state == 2)
            {
                //提现成功
                query.State = 2;
                DbEntityEntry entry = entities.Entry(query);
                entry.State = System.Data.Entity.EntityState.Modified;
                result      = entities.SaveChanges();

                //日志表记录
                if (result > 0)
                {
                    var model = entities.AroundUserFinance.Where(c => c.UserId == query.UserId).FirstOrDefault();
                    if (model != null)
                    {
                        model.AccountBalance         = model.AccountBalance - query.RemoveMoeny;
                        model.AccumulatedExpenditure = model.AccumulatedExpenditure + query.RemoveMoeny;
                        DbEntityEntry entry1 = entities.Entry(model);
                        entry1.State = System.Data.Entity.EntityState.Modified;
                        result       = entities.SaveChanges();

                        TimeSpan             ts  = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                        AroundUserFinanceLog log = new AroundUserFinanceLog
                        {
                            BusinessNumber    = Convert.ToInt64(ts.TotalMilliseconds).ToString(),
                            UserId            = model.UserId,
                            PaymentState      = 3,
                            TransactionType   = 1,
                            TransactionTime   = DateTime.Now,
                            TransactionAmount = query.RemoveMoeny,
                            Remarks           = "提现支出"
                        };
                        entities.AroundUserFinanceLog.Add(log);
                        result = entities.SaveChanges();
                    }
                }
            }
            else
            {
                query.State = 3;
                DbEntityEntry entry = entities.Entry(query);
                entry.State = System.Data.Entity.EntityState.Modified;
                result      = entities.SaveChanges();
                return(Ok(Respone.Success("提现失败")));
            }
            if (result > 0)
            {
                return(Ok(Respone.Success("提现成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
Example #7
0
        public IHttpActionResult ResetPassword([FromBody] JObject value)
        {
            int    result   = 0;
            int    id       = (int)value["Id"];
            string password = value["Password"].ToString();

            if (string.IsNullOrWhiteSpace(password) == true)
            {
                return(Ok(Respone.No("请输入密码")));
            }
            else
            {
                var pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
                var bid = entities.BackUser.Where(e => e.Id == id).FirstOrDefault();
                if (bid != null)
                {
                    bid.Password = pwd;
                    DbEntityEntry entry = entities.Entry(bid);
                    entry.State = System.Data.Entity.EntityState.Modified;
                    result      = entities.SaveChanges();
                }
            }
            if (result > 0)
            {
                return(Ok(Respone.Success("密码重置成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
Example #8
0
        public IHttpActionResult ChangeBackUserState([FromBody] JObject value)
        {
            int    result = 0;
            int    id     = (int)value["Id"];
            string name   = value["Name"].ToString();
            string phone  = value["Phone"].ToString();
            int    state  = (int)value["State"];
            var    bid    = entities.BackUser.Where(e => e.Id == id).FirstOrDefault();

            if (bid != null)
            {
                bid.State = state;
                bid.Name  = name;
                bid.Phone = phone;
                DbEntityEntry entry = entities.Entry(bid);
                entry.State = System.Data.Entity.EntityState.Modified;
                result      = entities.SaveChanges();
            }

            if (result > 0)
            {
                return(Ok(Respone.Success("修改成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
        public IHttpActionResult AddAsinKeyWord([FromBody] JObject value)
        {
            int     id        = (int)value["UserId"];
            int     countryId = (int)value["CountryId"];
            string  asin      = value["ASIN"].ToString();
            decimal price     = (decimal)value["Price"];

            AsinKeyWord asinKey = new AsinKeyWord
            {
                UserId    = id,
                CountryId = countryId,
                ASIN      = asin,
                State     = 1,
                Price     = price,
                BuyTime   = DateTime.Now
            };

            entities.AsinKeyWord.Add(asinKey);
            int result = entities.SaveChanges();

            if (result > 0)
            {
                return(Ok(Respone.Success("购买成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
Example #10
0
        public IHttpActionResult UserLogin([FromBody] JObject value)
        {
            int result   = 0;
            var phone    = value["Phone"].ToString();
            var password = value["Password"].ToString();
            var code     = value["Code"].ToString();

            if (Common.Cookie.getcookie("Code").ToUpper() != code.ToUpper())
            {
                return(Ok(Respone.No("验证码不正确")));
            }

            var pwd  = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
            var user = entities.AroundUser.Where(u => u.Phone == phone && u.PassWord == pwd && u.Enable == 1).FirstOrDefault();

            if (user == null)
            {
                return(Ok(Respone.No("用户名或者密码错误")));
            }
            else
            {
                System.Web.HttpContext.Current.Session["UserId"] = user.Id;
                return(Ok(Respone.Success(user.Id + "," + user.Name, "登录成功")));
            }
        }
Example #11
0
        public IHttpActionResult ChangerNotice([FromBody] JObject value)
        {
            int    result     = 0;
            int    id         = (int)value["Id"];
            string title      = value["Titles"].ToString();
            string contenting = value["Contenting"].ToString();
            var    nid        = entities.Notice.Where(e => e.Id == id).FirstOrDefault();

            if (nid != null)
            {
                nid.Title      = title;
                nid.Contenting = contenting;
                DbEntityEntry entry = entities.Entry(nid);
                entry.State = System.Data.Entity.EntityState.Modified;
                result      = entities.SaveChanges();
            }

            if (result > 0)
            {
                return(Ok(Respone.Success("修改成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
        public IHttpActionResult UserByAddShopCartPictureUpload()
        {
            string pric       = "";
            var    imageName1 = HttpContext.Current.Request.Files["image"];           // 从前台获取文件

            if (imageName1 != null)
            {
                string file = imageName1.FileName;

                string fileFormat = file.Split('.')[file.Split('.').Length - 1]; // 以“.”截取,获取“.”后面的文件后缀
                                                                                 //Regex imageFormat = new Regex(@"^(ZIP)|(RAR)|(7Z)|(CAB)"); // 验证文件后缀的表达式
                if (string.IsNullOrEmpty(file))                                  // 验证后缀,判断文件是否是所要上传的格式
                {
                    pric = "";                                                   //没有上传图片
                    return(Ok(Respone.No("上传文件名称不能为空")));
                }
                else
                {
                    string timeStamp     = DateTime.Now.Ticks.ToString();                       // 获取当前时间的string类型
                    string firstFileName = timeStamp.Substring(0, timeStamp.Length - 4);        // 通过截取获得文件名
                    string imageStr      = "/Images/UploadFiles/";                              // 获取保存图片的项目文件夹
                    string uploadPath    = HttpContext.Current.Server.MapPath("~/" + imageStr); // 将项目路径与文件夹合并
                    string pictureFormat = file.Split('.')[file.Split('.').Length - 1];         // 设置文件格式
                    string fileName      = firstFileName + "." + fileFormat;                    // 设置完整(文件名+文件格式)
                    string saveFile      = uploadPath + fileName;                               //文件路径
                    imageName1.SaveAs(saveFile);                                                // 保存文件
                    pric = imageStr + fileName;                                                 // 设置数据库保存图片的路径
                    return(Ok(Respone.Success(pric, "上传成功")));
                }
            }
            pric = "";               //没有上传图片
            return(Ok(Respone.No("请上传文件")));
        }
        public IHttpActionResult AddOrderMailboxQuery([FromBody] JObject value)
        {
            int               uid         = (int)value["UserId"];
            int               countryId   = (int)value["CountryId"];
            decimal           price       = (decimal)value["Price"];
            string            asin        = value["ASIN"].ToString();
            string            orderNumber = value["OrderNumber"].ToString();
            OrderMailboxQuery order       = new OrderMailboxQuery
            {
                UserId      = uid,
                State       = 1,
                CountryId   = countryId,
                Price       = price,
                ASIN        = asin,
                OrderNumber = orderNumber,
                SubTime     = DateTime.Now
            };

            entities.OrderMailboxQuery.Add(order);
            int result = entities.SaveChanges();

            if (result > 0)
            {
                return(Ok(Respone.Success("提交成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
Example #14
0
        public IHttpActionResult AddPagNoBadEvaluate([FromBody] JObject value)
        {
            int     id        = (int)value["UserId"];
            int     countryId = (int)value["CountryId"];
            string  asin      = value["ASIN"].ToString();
            decimal price     = (decimal)value["Price"];

            HomePagNoBadEvaluate homePag = new HomePagNoBadEvaluate
            {
                UserId    = id,
                ASIN      = asin,
                CountryId = countryId,
                State     = 1,
                Price     = price,
                BuyTime   = DateTime.Now
            };

            entities.HomePagNoBadEvaluate.Add(homePag);
            int result = entities.SaveChanges();

            if (result > 0)
            {
                return(Ok(Respone.Success("购买成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
        public IHttpActionResult AddLinkMailboxQuery([FromBody] JObject value)
        {
            int     uid       = (int)value["Uid"];
            int     countryId = (int)value["CountryId"];
            string  reviewId  = value["ReviewId"].ToString();
            decimal price     = (decimal)value["Price"];

            LinkMailboxQuery mailboxQuery = new LinkMailboxQuery
            {
                UserId     = uid,
                State      = 1,
                ReviewLink = reviewId,
                SubTime    = DateTime.Now,
                Price      = price,
                CountryId  = countryId
            };

            entities.LinkMailboxQuery.Add(mailboxQuery);
            int result = entities.SaveChanges();

            if (result > 0)
            {
                return(Ok(Respone.Success("提交成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
Example #16
0
        public IHttpActionResult AddShopReport([FromBody] JObject value)
        {
            int     id        = (int)value["UserId"];
            int     countryId = (int)value["CountryId"];
            string  shopEmail = value["ShopEmail"].ToString();
            string  shopId    = value["ShopId"].ToString();
            decimal price     = (decimal)value["Price"];

            ShopReport report = new ShopReport
            {
                UserId    = id,
                CountryId = countryId,
                ShopEmail = shopEmail,
                ShopId    = shopId,
                Price     = price,
                State     = 1,
                BuyTime   = DateTime.Now
            };

            entities.ShopReport.Add(report);
            int result = entities.SaveChanges();

            if (result > 0)
            {
                return(Ok(Respone.Success("购买成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
        public IHttpActionResult AddCountry([FromBody] JObject value)
        {
            int    result           = 0;
            string countryName      = value["CountryName"].ToString();
            string counteyShorthand = value["CounteyShorthand"].ToString();

            var query = entities.Country.Where(e => e.CountryName == countryName || e.CounteyShorthand == counteyShorthand).FirstOrDefault();

            if (query != null)
            {
                return(Ok(Respone.No("国家名称或简写已存在!")));
            }
            Country country = new Country();

            country.CountryName      = countryName;
            country.CounteyShorthand = counteyShorthand;
            country.State            = 1;
            entities.Country.Add(country);
            result = entities.SaveChanges();
            if (result > 0)
            {
                return(Ok(Respone.Success("添加成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
Example #18
0
        public IHttpActionResult AddBackUser([FromBody] JObject value)
        {
            int    result    = 0;
            string name      = value["Name"].ToString();
            string loginname = value["LoginName"].ToString();
            string password  = value["Password"].ToString();
            string phone     = value["Phone"].ToString();
            var    pwd       = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");

            var query = entities.BackUser.Where(e => e.LoginName == loginname).FirstOrDefault();

            if (query != null)
            {
                return(Ok(Respone.No("该账号已存在!")));
            }
            BackUser backUser = new BackUser();

            backUser.Name      = name;
            backUser.LoginName = loginname;
            backUser.Password  = pwd;
            backUser.Phone     = phone;
            backUser.State     = 1;
            entities.BackUser.Add(backUser);
            result = entities.SaveChanges();
            if (result > 0)
            {
                return(Ok(Respone.Success("添加成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
Example #19
0
        public IHttpActionResult ResetPwd([FromBody] JObject value)
        {
            int    result          = 0;
            int    id              = (int)value["Id"];
            string oldPassWord     = value["OldPassWord"].ToString();
            string newPassWord     = value["NewPassWord"].ToString();
            string confirmPassWord = value["ConfirmPassWord"].ToString();

            if (newPassWord != confirmPassWord)
            {
                return(Ok(Respone.No("新密码不一致")));
            }
            var pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(oldPassWord, "MD5");

            var user = entities.AroundUser.Where(e => e.Id == id && e.PassWord == pwd).FirstOrDefault();

            if (user == null)
            {
                return(Ok(Respone.No("原密码不正确")));
            }
            var newpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(newPassWord, "MD5");

            user.PassWord = newpwd;
            result        = entities.SaveChanges();
            if (result > 0)
            {
                return(Ok(Respone.Success("修改成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
        public IHttpActionResult AddRole([FromBody] JObject value)
        {
            int    result   = 0;
            string roleName = value["RoleName"].ToString();
            string remarks  = value["Remarks"].ToString();

            var query = entities.Role.Where(e => e.RoleName == roleName).FirstOrDefault();

            if (query != null)
            {
                return(Ok(Respone.No("该角色已存在!")));
            }
            Role role = new Role();

            role.RoleName = roleName;
            role.Remarks  = remarks;
            entities.Role.Add(role);
            result = entities.SaveChanges();
            if (result > 0)
            {
                return(Ok(Respone.Success("添加成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
        public IHttpActionResult AddBugQuery([FromBody] JObject value)
        {
            int     id              = (int)value["UserId"];
            int     countryId       = (int)value["CountryId"];
            string  registeredEmail = value["RegisteredEmail"].ToString();
            string  sellerIdOrASIN  = value["SellerIdOrASIN"].ToString();
            decimal price           = (decimal)value["Price"];
            string  serviceName     = value["ServiceName"].ToString();

            BugQuery bug = new BugQuery
            {
                UserId          = id,
                CountryId       = countryId,
                RegisteredEmail = registeredEmail,
                SellerIdOrAsin  = sellerIdOrASIN,
                Price           = price,
                State           = 1,
                ServiceName     = serviceName,
                SubTime         = DateTime.Now
            };

            entities.BugQuery.Add(bug);
            int result = entities.SaveChanges();

            if (result > 0)
            {
                return(Ok(Respone.Success("提交成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
        public IHttpActionResult ChangeUserByAddShopCartStateOrMoney(ChangeBadEvaluateModel model)
        {
            int result = 0;

            if (model.State == 1)
            {
                for (int i = 0; i < model.Id.Length; i++)
                {
                    int c     = model.Id[i];
                    var query = entities.AddShopCart.Where(e => e.Id == c).FirstOrDefault();
                    if (query != null)
                    {
                        query.State = 2;
                        //DbEntityEntry entry = entities.Entry(query);
                        //entry.State = System.Data.Entity.EntityState.Modified;
                        result = entities.SaveChanges();
                    }
                }
            }
            if (model.State == 2)
            {
                for (int i = 0; i < model.Id.Length; i++)
                {
                    int c     = model.Id[i];
                    var query = entities.AddShopCart.Where(e => e.Id == c).FirstOrDefault();
                    if (query != null)
                    {
                        query.State = 4;
                        //DbEntityEntry entry = entities.Entry(query);
                        //entry.State = System.Data.Entity.EntityState.Modified;
                        result = entities.SaveChanges();
                    }
                }
            }
            if (model.State == 3)
            {
                for (int i = 0; i < model.Id.Length; i++)
                {
                    int c     = model.Id[i];
                    var query = entities.AddShopCart.Where(e => e.Id == c).FirstOrDefault();
                    if (query != null)
                    {
                        query.Price = model.Price;
                        //DbEntityEntry entry = entities.Entry(query);
                        //entry.State = System.Data.Entity.EntityState.Modified;
                        result = entities.SaveChanges();
                    }
                }
            }

            if (result > 0)
            {
                return(Ok(Respone.Success("修改成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
        public IHttpActionResult EndAddShopCartTask([FromBody] JObject value)
        {
            try
            {
                int     result = 0;
                decimal total  = 0;
                int     id     = (int)value["Id"];
                int     number = (int)value["Number"];
                var     query  = entities.AddShopCart.Where(e => e.Id == id).FirstOrDefault();
                if (query != null)
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        total            = Convert.ToDecimal(query.Price) * number;
                        query.State      = 3;
                        query.TotalPrice = total;
                        query.Actual     = number;
                        DbEntityEntry entry = entities.Entry(query);
                        entry.State = System.Data.Entity.EntityState.Modified;

                        //账户扣款
                        var customerFinance = entities.AroundUserFinance.Where(t => t.UserId == query.UserId).FirstOrDefault();
                        customerFinance.AccountBalance         = customerFinance.AccountBalance - query.TotalPrice;
                        customerFinance.AccumulatedExpenditure = customerFinance.AccumulatedExpenditure + query.TotalPrice;
                        DbEntityEntry entryc = entities.Entry(customerFinance);
                        entryc.State = System.Data.Entity.EntityState.Modified;

                        //日志
                        TimeSpan             ts  = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                        AroundUserFinanceLog log = new AroundUserFinanceLog
                        {
                            BusinessNumber    = Convert.ToInt64(ts.TotalMilliseconds).ToString(),
                            UserId            = query.UserId,
                            PaymentState      = 21,
                            TransactionType   = 1,                            //1扣款,2:充值,3退款
                            TransactionTime   = DateTime.Now,
                            TransactionAmount = query.TotalPrice,
                            Remarks           = "任务:" + query.Id + " 加购总额支出"
                        };
                        entities.AroundUserFinanceLog.Add(log);
                        result = entities.SaveChanges();
                        scope.Complete();
                    }
                }
                if (result > 0)
                {
                    return(Ok(Respone.Success("加购任务已完成")));
                }
                else
                {
                    return(Ok(Respone.No("发生了点问题,请稍后再试")));
                }
            }
            catch (Exception ex)
            {
                return(Ok(ex.ToString()));
            }
        }
Example #24
0
        public IHttpActionResult ChangeUserByEvaluateStateOrMoney(ChangeBadEvaluateModel model)
        {
            int result = 0;

            if (model.State == 1)
            {
                for (int i = 0; i < model.Id.Length; i++)
                {
                    int c     = model.Id[i];
                    var query = entities.Evaluate.Where(e => e.Id == c).FirstOrDefault();
                    if (query != null)
                    {
                        query.State = 2;
                        result      = entities.SaveChanges();
                    }
                }
            }
            if (model.State == 2)
            {
                for (int i = 0; i < model.Id.Length; i++)
                {
                    int c     = model.Id[i];
                    var query = entities.Evaluate.Where(e => e.Id == c).FirstOrDefault();
                    if (query != null)
                    {
                        query.State = 5;
                        result      = entities.SaveChanges();
                    }
                }
            }
            if (model.State == 3)
            {
                for (int i = 0; i < model.Id.Length; i++)
                {
                    int c     = model.Id[i];
                    var query = entities.Evaluate.Where(e => e.Id == c).FirstOrDefault();
                    if (query != null)
                    {
                        query.Price = model.Price;
                        result      = entities.SaveChanges();
                    }
                }
            }

            if (result > 0)
            {
                return(Ok(Respone.Success("修改成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
 public IHttpActionResult AddEvaluate(EvaluateModel evaluateModel)
 {
     try
     {
         int result = 0;
         int sum    = 0;
         if (evaluateModel.tieleAndMeaageModels != null && evaluateModel.tieleAndMeaageModels.Length > 0)
         {
             Evaluate e = new Evaluate();
             using (TransactionScope scope = new TransactionScope())
             {
                 foreach (var item in evaluateModel.tieleAndMeaageModels)
                 {
                     e.UserId          = evaluateModel.UserId;
                     e.CountryId       = evaluateModel.CountryId;
                     e.ShopId          = evaluateModel.ShopId;
                     e.Title           = item.Title;
                     e.Message         = item.Message;
                     e.ASIN            = evaluateModel.Asin;
                     e.State           = 1;
                     e.Price           = evaluateModel.Price;
                     e.KeyWord         = evaluateModel.KeyWord;
                     e.Productlocation = evaluateModel.Productlocation;
                     e.AddTimes        = DateTime.Now;
                     e.Remarks         = evaluateModel.Remarks;
                     entities.Evaluate.Add(e);
                     result = entities.SaveChanges();
                     sum++;
                 }
                 scope.Complete();
             }
         }
         if (result > 0)
         {
             return(Ok(Respone.Success("添加成功")));
         }
         else
         {
             return(Ok(Respone.No("发生了点问题,请稍后再试")));
         }
     }
     catch (Exception ex)
     {
         return(Ok(Respone.No(ex.ToString())));
     }
 }
        public IHttpActionResult ChangeCountry([FromBody] JObject value)
        {
            int    result           = 0;
            string countryName      = value["CountryName"].ToString();
            string counteyShorthand = value["CounteyShorthand"].ToString();
            int    state            = (int)value["State"];
            int    id    = (int)value["Id"];
            var    query = entities.Country.Where(e => e.Id != id).ToList();
            Dictionary <string, string> d = new Dictionary <string, string>();

            foreach (var item in query)
            {
                string name      = item.CountryName;
                string shorthand = item.CounteyShorthand;
                d.Add(name, shorthand);
            }
            foreach (var item in d)
            {
                if (countryName == item.Key || counteyShorthand == item.Value)
                {
                    return(Ok(Respone.No("已存在国家或简称")));
                }
            }

            var cid = entities.Country.Where(e => e.Id == id).FirstOrDefault();

            if (cid != null)
            {
                cid.CounteyShorthand = counteyShorthand;
                cid.CountryName      = countryName;
                cid.State            = state;

                DbEntityEntry entry = entities.Entry(cid);
                entry.State = System.Data.Entity.EntityState.Modified;
                result      = entities.SaveChanges();
            }

            if (result > 0)
            {
                return(Ok(Respone.Success("修改成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
        public IHttpActionResult ChangeRoleName([FromBody] JObject value)
        {
            int           result   = 0;
            int           id       = (int)value["Id"];
            string        roleName = value["RoleName"].ToString();
            string        remarks  = value["Remarks"].ToString();
            var           query    = entities.Role.Where(e => e.Id != id).ToList();
            List <string> list     = new List <string>();

            foreach (var item in query)
            {
                string name = item.RoleName;
                list.Add(name);
            }
            foreach (var item in list)
            {
                if (roleName == item)
                {
                    return(Ok(Respone.No("该角色已存在!")));
                }
            }
            var rid = entities.Role.Where(e => e.Id == id).FirstOrDefault();

            if (rid != null)
            {
                rid.RoleName = roleName;
                rid.Remarks  = remarks;
                DbEntityEntry entry = entities.Entry(rid);
                entry.State = System.Data.Entity.EntityState.Modified;
                result      = entities.SaveChanges();
            }

            if (result > 0)
            {
                return(Ok(Respone.Success("修改成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
        public IHttpActionResult AddShopCartFiles([FromBody] JObject value)
        {
            int    result = 0;
            int    id     = (int)value["Id"];
            string files  = value["Files"].ToString();
            var    query  = entities.AddShopCart.Where(e => e.Id == id).FirstOrDefault();

            if (query != null)
            {
                query.Images = files;
                result       = entities.SaveChanges();
            }
            if (result > 0)
            {
                return(Ok(Respone.Success("文件上传成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }
Example #29
0
        public IHttpActionResult UserLogin([FromBody] JObject value)
        {
            int result   = 0;
            var name     = string.Empty;
            var password = string.Empty;

            if (value != null)
            {
                if (value["LoginName"] == null)
                {
                    return(Ok(Respone.No("用户名不能为空")));
                }
                name = value["LoginName"].ToString();
                if (value["Password"] == null)
                {
                    return(Ok(Respone.No("密码不能为空")));
                }
                password = value["Password"].ToString();
            }
            else
            {
                return(null);
            }
            var pwd  = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
            var user = entities.BackUser.Where(u => u.LoginName == name && u.Password == pwd && u.State == 1).FirstOrDefault();

            if (user == null)
            {
                return(Ok(Respone.No("用户名或者密码错误")));
            }
            else
            {
                //Dictionary<int, string> us = new Dictionary<int, string>();
                //us.Add(user.Id, user.Name);

                //var json = JsonConvert.SerializeObject(us);
                //var s=json.Replace("\"", "");
                return(Ok(Respone.Success(user.Id + "," + user.Name, "登录成功")));
            }
        }
        public IHttpActionResult AddtoShopCart([FromBody] JObject value)
        {
            int     uid             = (int)value["UserId"];
            int     countryId       = (int)value["CountryId"];
            decimal price           = (decimal)value["Price"];
            string  shopId          = value["ShopId"].ToString();
            int     number          = (int)value["Number"];
            string  asin            = value["ASIN"].ToString();
            string  keyWord         = value["KeyWord"].ToString();
            string  productlocation = value["Productlocation"].ToString();
            string  remarks         = value["Remarks"].ToString();

            var addShopCart = new AddShopCart
            {
                UserId          = uid,
                State           = 1,
                AddTimes        = DateTime.Now,
                Price           = price,
                CountryId       = countryId,
                ShopId          = shopId,
                Number          = number,
                ASIN            = asin,
                KeyWord         = keyWord,
                Productlocation = productlocation,
                Remarks         = remarks
            };

            entities.AddShopCart.Add(addShopCart);
            int result = entities.SaveChanges();

            if (result > 0)
            {
                return(Ok(Respone.Success("提交成功")));
            }
            else
            {
                return(Ok(Respone.No("发生了点问题,请稍后再试")));
            }
        }