Example #1
0
        public async Task <ActionResult> ConfirmNoteItems(ConfirmNoteItemsDTO availableItems)
        {
            NoteModel note = await noteCosmosDBService.GetNote(availableItems.NoteID);

            if (note != null)
            {
                Model.Shop shop = note.Shops.First(x => x.ShopEmail.Equals(availableItems.UserEmail));
                shop.Notes = mapper.Map <NoteModel>(availableItems).Notes;
                note.Shops.RemoveAll(x => x.ShopEmail.Equals(availableItems.UserEmail));
                shop.ResponseTime = DateTime.Now;
                shop.ShopStatus   = 1;
                note.Shops.Add(shop);
                if (await noteCosmosDBService.ReplaceDocumentAsync(note.SelfLink, note))
                {
                    string title = $"The shop {shop.ShopName} has responded to your order";
                    var    data  = new Dictionary <string, string>();
                    data.Add("orderid", note.Id);
                    var notificationData = new NotificationData()
                    {
                        msgBody   = title,
                        msgTitle  = "A Shop has responed to your order",
                        tokenList = note.PhoneGuid
                                    //options = data
                    };

                    pushNotificationService.SendNotification(notificationData);
                    return(Ok("Note Successfully Updated"));
                }
                return(StatusCode(500, "Unable to update the status"));
            }
            return(BadRequest("Specified Note doesn't exist"));
        }
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnNew_Click(object sender, EventArgs e)
        {
            string name     = this.Name.Text.Trim();
            string tel      = this.Tel.Text.Trim();
            string address  = this.Address.Text.Trim();
            string describe = this.Describe.Text.Trim();
            string remark   = this.Remark.Text.Trim();

            try
            {
                using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
                {
                    ZLzuche.Model.Shop shop = new Model.Shop();
                    shop.Name     = name;
                    shop.Tel      = tel;
                    shop.Address  = address;
                    shop.Describe = describe;
                    shop.Remark   = remark;
                    entity.AddToShop(shop);
                    entity.SaveChanges();
                }
                Response.Write("<script language='javascript'>window.opener.location.reload();</script>");
                Response.Write("<script language='javascript'>window.opener=null;window.close();</script>");
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('新增失败');</script>");
                return;
            }
        }
Example #3
0
 static void Main(string[] args)
 {
     try
     {
         var user = new Model.User()
         {
             UserName = "******",
             Password = "******"
         };
         var shop = new Model.Shop()
         {
             ShopName = "shopex",
             ShopUrl  = "http://www.shopex.cn"
         };
         ChannelFactory <ISeller> _factory = new ChannelFactory <ISeller>(new WSHttpBinding(),
                                                                          new EndpointAddress("http://localhost:8734/Seller"));
         var _client = _factory.CreateChannel();
         Console.WriteLine(_client.Add(shop, user) == true ? "成功" : "失败");
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         Console.ReadLine();
     }
 }
 /// <summary>
 /// 保存
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnNew_Click(object sender, EventArgs e)
 {
     string name = this.Name.Text.Trim();
     string tel = this.Tel.Text.Trim();
     string address = this.Address.Text.Trim();
     string describe = this.Describe.Text.Trim();
     string remark = this.Remark.Text.Trim();
     try
     {
         using (ZLzuche.Model.ZLzucheEntities entity = new Model.ZLzucheEntities())
         {
             ZLzuche.Model.Shop shop = new Model.Shop();
             shop.Name = name;
             shop.Tel = tel;
             shop.Address = address;
             shop.Describe = describe;
             shop.Remark = remark;
             entity.AddToShop(shop);
             entity.SaveChanges();
         }
         Response.Write("<script language='javascript'>window.opener.location.reload();</script>");
         Response.Write("<script language='javascript'>window.opener=null;window.close();</script>");
     }
     catch (Exception ex)
     {
         ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('新增失败');</script>");
         return;
     }
 }
Example #5
0
        public async Task <IActionResult> GetById(int id)
        {
            Model.Shop entity = await FindShopById(id);

            if (entity == null)
            {
                return(NotFound());
            }
            return(Ok(CreateDTOFromEntity(entity)));
        }
Example #6
0
        private Model.Shop CreateEntityFromDTO(DTO.Shop dto)
        {
            var shop = new Model.Shop(dto.Name, dto.OwnerId);

            if (dto.RowVersion != null)
            {
                shop.RowVersion = dto.RowVersion;
            }
            return(shop);
        }
Example #7
0
 private static DTO.Shop CreateDTOFromEntity(Model.Shop entity)
 {
     //fixme: comment améliorer cette implémentation?
     return(new DTO.Shop()
     {
         Id = entity.Id,
         Name = entity.Name,
         RowVersion = entity.RowVersion,
         OwnerId = entity.OwnerId
     });
 }
Example #8
0
        public async Task <IActionResult> Post([FromBody] DTO.Shop dto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Model.Shop entity = CreateEntityFromDTO(dto);
            _context.Shops.Add(entity);
            await _context.SaveChangesAsync();

            return(Created($"api/Shops/{entity.Id}", CreateDTOFromEntity(entity)));
        }
Example #9
0
        private void DoAdd()
        {
            Model.manager model        = new Model.manager();
            Model.Dealer  model_dealer = new Model.Dealer();
            Model.Shop    model_shop   = new Model.Shop();
            BLL.manager   bll          = new BLL.manager();
            //model.role_id = int.Parse(ddlRoleId.SelectedValue);
            model.role_id   = 2;
            model.role_type = 2;
            model.is_lock   = 1;
            //检测用户名是否重复
            //if (bll.Exists(txtUserName.Text.Trim()))
            //{
            //    return false;
            //}
            model.user_name = txtname.Text.Trim();
            //获得6位的salt加密字符串
            model.salt = Utils.GetCheckCode(6);
            //以随机生成的6位字符串做为密钥加密
            model.password = DESEncrypt.Encrypt(txtPassword.Text.Trim(), model.salt);

            model.telephone = txtTelephone.Text.Trim();
            //model.email = txtEmail.Text.Trim();
            //model.add_time = DateTime.Now;
            //model.Companyname = txtcompanyname.Text.Trim();
            //model.Name = txtname.Text.Trim();
            //model.Phone = txtphone.Text.Trim();
            //model.Position = txtposition.Text.Trim();
            //model.Address = txtaddress.Text.Trim();

            model_dealer.DealerCode  = txtDealerCode.Text.Trim();
            model_dealer.DealerName  = txtDealerName.Text.Trim();
            model_shop.ProvinceCode  = Request.Form["drpProvice"];
            model_shop.CityCode      = Request.Form["city"];
            model_shop.TownCode      = Request.Form["town"];
            model_shop.DetailAddress = txtDetailAddress.Text.Trim();
            model_shop.ShopName      = txtShopName.Text.Trim();
            model_shop.Postcode      = txtPostcode.Text.Trim();
            try
            {
                bll.Add(model, model_shop);
                Page.ClientScript.RegisterStartupScript(GetType(), "", "mess()", true);
            }
            catch (Exception)
            { }
            //if (bll.Add(model) > 0)
            //{
            //    //AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加管理员:" + model.user_name); //记录日志
            //    return true;
            //}
            //return false;
        }
Example #10
0
        public async Task <IActionResult> GetByShop(int shopId)
        {
            Model.Shop shopFound = await FindShopById(shopId);

            if (shopFound == null)
            {
                return(NotFound());
            }

            IEnumerable <DTO.OpeningPeriod> dtos = shopFound.OpeningPeriods.Select(CreateDTOFromEntity);

            return(Ok(dtos));
        }
Example #11
0
        public async Task <IActionResult> Delete(int id)
        {
            Model.Shop shop = await FindShopById(id);

            if (shop == null)
            {
                // todo: débat: si l'on demande une suppression d'une entité qui n'existe pas
                // s'agit-il vraiment d'un cas d'erreur?
                return(NotFound());
            }
            _context.Shops.Remove(shop);
            await _context.SaveChangesAsync();

            return(Ok());
        }
Example #12
0
        public async Task <IActionResult> Put(int id, [FromBody] DTO.Shop dto)
        {
            //fixme: comment valider que le client envoie toujours quelque chose de valide?
            Model.Shop entity = await FindShopById(id);

            if (entity == null)
            {
                return(NotFound());
            }
            //fixme: améliorer cette implémentation
            entity.Name    = dto.Name;
            entity.OwnerId = dto.OwnerId;
            //fixme: le premier RowVersion n'a pas d'impact.
            // Attardez-vous à comprendre pour quelle raison.
            // entity.RowVersion = dto.RowVersion;
            _context.Entry(entity).OriginalValues["RowVersion"] = dto.RowVersion;
            //pas de gestion des opening periods (voir autre controller).
            await _context.SaveChangesAsync();

            return(Ok(CreateDTOFromEntity(entity)));
        }
Example #13
0
        public async Task <IActionResult> Post(int shopId, [FromBody] DTO.OpeningPeriod dto)
        {
            Model.Shop shop = await FindShopById(shopId);

            if (shop == null)
            {
                return(NotFound());
            }
            int userId = int.Parse(User.Claims.First(c => c.Type == PrivateClaims.UserId).Value);

            #region ...
            if (!User.IsInRole(Constants.Roles.Admin) && shop.OwnerId != userId)
            {
                return(Forbid());
            }
            #endregion

            Model.OpeningPeriod entity = CreateEntityFromDTO(dto);
            shop.AddOpeningPeriod(entity);
            await _context.SaveChangesAsync();

            return(Created($"api/{entity.Id}", CreateDTOFromEntity(entity)));
        }
Example #14
0
 public void Add(Model.manager model_manager, Model.Shop model_shop)
 {
     dal.Add(model_manager, model_shop);
 }
Example #15
0
        public void Add(Model.manager model, Model.Shop model_shop)
        {
            StringBuilder strSql = new StringBuilder();

            //strSql.Append(" declare @DealerID int ");
            //strSql.Append(" insert into Dealer(DealerCode,DealerName,CreateTime)values(@DealerCode,@DealerName,getdate())");
            //strSql.Append(";set @DealerID= @@IDENTITY");

            strSql.Append(" declare @ShopID int ");
            strSql.Append(" insert into Shop(ShopCode,ShopName,ProvinceCode,CityCode,TownCode,DetailAddress,CreateTime,Postcode)values(@ShopCode,@ShopName,@ProvinceCode,@CityCode,@TownCode,@DetailAddress,getdate(),@Postcode)");
            strSql.Append(";set @ShopID= @@IDENTITY ");

            strSql.Append(" insert into " + databaseprefix + "manager(");
            strSql.Append("role_id,role_type,user_name,password,salt,real_name,telephone,email,is_lock,add_time,ShopID)");
            strSql.Append(" values (");
            strSql.Append("@role_id,@role_type,@user_name,@password,@salt,@real_name,@telephone,@email,@is_lock,@add_time,@ShopID)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@role_id",       SqlDbType.Int,         4),
                new SqlParameter("@role_type",     SqlDbType.Int,         4),
                new SqlParameter("@user_name",     SqlDbType.NVarChar,  100),
                new SqlParameter("@password",      SqlDbType.NVarChar,  100),
                new SqlParameter("@salt",          SqlDbType.NVarChar,   20),
                new SqlParameter("@real_name",     SqlDbType.NVarChar,   50),
                new SqlParameter("@telephone",     SqlDbType.NVarChar,   30),
                new SqlParameter("@email",         SqlDbType.NVarChar,   30),
                new SqlParameter("@is_lock",       SqlDbType.Int,         4),
                new SqlParameter("@add_time",      SqlDbType.DateTime),

                //new SqlParameter("@DealerCode", SqlDbType.VarChar,50),
                //new SqlParameter("@DealerName", SqlDbType.NVarChar,150),

                new SqlParameter("@ShopCode",      SqlDbType.VarChar,    50),
                new SqlParameter("@ShopName",      SqlDbType.NVarChar,  100),
                new SqlParameter("@ProvinceCode",  SqlDbType.VarChar,     6),
                new SqlParameter("@CityCode",      SqlDbType.VarChar,     6),
                new SqlParameter("@TownCode",      SqlDbType.VarChar,     6),
                new SqlParameter("@DetailAddress", SqlDbType.NVarChar,  150),
                new SqlParameter("@Postcode",      SqlDbType.VarChar, 10)
            };
            parameters[0].Value = model.role_id;
            parameters[1].Value = model.role_type;
            parameters[2].Value = model.user_name;
            parameters[3].Value = model.password;
            parameters[4].Value = model.salt;
            parameters[5].Value = model.real_name;
            parameters[6].Value = model.telephone;
            parameters[7].Value = model.email;
            parameters[8].Value = model.is_lock;
            parameters[9].Value = model.add_time;

            //parameters[10].Value = model_dealer.DealerCode;
            //parameters[11].Value = model_dealer.DealerName;

            parameters[10].Value = model_shop.ShopCode;
            parameters[11].Value = model_shop.ShopName;
            parameters[12].Value = model_shop.ProvinceCode;
            parameters[13].Value = model_shop.CityCode;
            parameters[14].Value = model_shop.TownCode;
            parameters[15].Value = model_shop.DetailAddress;
            parameters[16].Value = model_shop.Postcode;
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            ht.Add(strSql, parameters);

            try
            {
                DbHelperSQL.ExecuteSqlTran(ht);
            }
            catch
            {
                throw;
            }
        }