Пример #1
0
 public static MessageResult AssignShop(AssignShop assign, string addedBy)
 {
     try
     {
         using (SqlConnection conn = new SqlConnection(DBConn))
         {
             querry = $@"update AssignShop set Status = '{0}' where UserID = @UserID 
             insert into AssignShop(ID,ShopsID,UserID,Status,AddedAt,AddedBy)
             values(@ID,@ShopsID,@UserID,@Status,@AddedAt,@AddedBy)";
             using (SqlCommand cmd = new SqlCommand(querry, conn))
             {
                 conn.Open();
                 cmd.Parameters.AddWithValue("@ID", Guid.NewGuid());
                 cmd.Parameters.AddWithValue("@ShopsID", assign.ShopsID);
                 cmd.Parameters.AddWithValue("@UserID", assign.UserID);
                 cmd.Parameters.AddWithValue("@Status", 1);
                 cmd.Parameters.AddWithValue("@AddedAt", DateTime.Now);
                 cmd.Parameters.AddWithValue("@AddedBy", addedBy);
                 cmd.ExecuteReader();
                 conn.Close();
                 mes.Status  = "success";
                 mes.Message = "Shop assidned to user successfully";
             }
         }
     }
     catch (Exception e)
     {
         mes.Status  = "warning";
         mes.Message = "Failed! reload and try again";
     }
     return(mes);
 }
Пример #2
0
        public JsonResult AssignToShop([FromBody] AssignDriverToShopModel assing)
        {
            // for the purpose of re using table AssignShop
            // i have in this case assummed that user id is the driver id , hope that helps
            var d = new AssignShop();

            d.ShopsID = assing.ShopID;
            d.UserID  = assing.DriverID;
            string AssignBy = Constant.GetUserID();

            return(Json(ShopSQL.AssignShop(d, AssignBy)));
        }
Пример #3
0
        public JsonResult AssignShop([FromBody] AssignShop shop)
        {
            string AddedBy = Constant.GetUserID();

            return(Json(ShopSQL.AssignShop(shop, AddedBy), JsonRequestBehavior.AllowGet));
        }