コード例 #1
0
        public bool AddCandy(AddCandyDto newCandy)
        {
            using (var db = new SqlConnection(_connectionString))
            {
                var sql = @"
                        INSERT INTO [Candy]
                                    ([Name]
                                    ,[IsHard]
                                    ,[IsChocolate]
                                    ,[IsFruity]
                                    ,[Cost]
                                    ,[WillTrade])
	                        OUTPUT inserted.*
                                VALUES
                                    (@name
                                    ,'false'
                                    ,'true'
                                    ,'false'
                                    ,1
                                    ,'true')";


                return(db.Execute(sql, newCandy) == 1);
            }
        }
コード例 #2
0
        public bool AddCandy(AddCandyDto newCandy)
        {
            using (var db = new SqlConnection(_connectionString))
            {
                var sql = @"INSERT INTO [dbo].[Members]
                                         (
                                         [username]
                                         ,[email]
                                         ,[status]
                                         ,[billingActive]
                                        ,[has2FA]
                                         ,[hasSSO]
                                         ,[userid]
                                         ,[fullname]
                                         ,[displayname])

                           output inserted.*
                           VALUES
                                        (
                                        
                                        @UserName
                                        ,@Email
                                        ,@Status
                                        ,@BillingActive
                                        ,@Has2FA
                                        ,@HasSSO
                                        ,@UserId
                                        ,@FullName
                                        ,@DisplayName)";

                return(db.Execute(sql, newCandy) == 1);
            }
            //throw new NotImplementedException();
        }
コード例 #3
0
        public bool AddCandy(AddCandyDto newCandy)
        {
            using (var db = new SqlConnection(_connectionString))
            {
                var sql         = @"SELECT *
                            FROM [Candy]
                            WHERE ([Name] = @name AND [Size] = @size)";
                var parameters  = new { name = newCandy.Name, size = newCandy.Size };
                var doubleCheck = db.Query <Candy>(sql, parameters).ToList();

                if (doubleCheck.Count() == 0)
                {
                    var sql2 = @"
                    INSERT INTO [Candy]
                        ([Name]
                        ,[TypeId]
                        ,[ImgUrl]
                        ,[Size])
                    VALUES
                        (@name
                        ,@typeId
                        ,@imgUrl
                        ,@size)";

                    return(db.Execute(sql2, newCandy) == 1);
                }
                return(false);
            }
        }
コード例 #4
0
 public bool AddCandy(AddCandyDto newCandy)
 {
     using (var db = new SqlConnection(_connectionString))
     {
         var sql = @"INSERT INTO Candy
                    ([Name] ,[Type] ,[Flavor] ,[Owner])
                    VALUES (@name, @type, @flavor, @owner)";
         return(db.Execute(sql, newCandy) == 1);
     }
 }
コード例 #5
0
        public bool AddCandy(AddCandyDto newCandy)
        {
            string sql = "INSERT INTO [Candy] (Candy) Values (@newCandy);";

            using (var db = new SqlConnection(_connectionString))
            {
                var CandyAdded = db.Execute(sql, new { newCandy });

                return(CandyAdded == 1);
            }
        }
コード例 #6
0
 public IActionResult Add(AddCandyDto newCandy)
 {
     if (_repo.AddCandy(newCandy))
     {
         return(Created($"candy/{newCandy.Name}", newCandy));
     }
     else
     {
         return(BadRequest());
     }
 }
コード例 #7
0
        public IActionResult Add(AddCandyDto newCandy)
        {
            var candy = new Candy
            {
                Name    = newCandy.Name,
                Texture = newCandy.Texture
            };

            _repo.AddCandy(newCandy);
            return(Ok());
        }
コード例 #8
0
 public bool AddCandy(AddCandyDto newCandy)
 {
     using (var db = new SqlConnection(_connectionString))
     {
         var sql = @"
                     Insert into Candy
                     ([Name],[candytypeId],[Candyflavor])
                     output inserted.*
                     values (@name,@candytypeid,@candyflavor)";
         return(db.Execute(sql, newCandy) == 1);
     }
 }
コード例 #9
0
        public bool AddCandy(AddCandyDto newCandy)
        {
            using (var db = new SqlConnection(_connectionString))
            {
                var sql = @"
                            Insert into CandyMarket
                               ([Name],Type,Flavor,isExpired)
                               output inserted.*
                               values (@name,@type,@flavor,@isExpired)";

                return(db.Execute(sql, newCandy) == 1);
            }
        }
コード例 #10
0
        public bool AddCandy(AddCandyDto newCandy)
        {
            using (var db = new SqlConnection(_connectionString))
            {
                var cmd = @"INSERT INTO [Candy]([Name])
                            VALUES(@Name)";


                return(db.Execute(cmd, newCandy) == 1);
                //return db.Execute(cmd, new { Name = newCandy.Name, Type = newCandy.Type}}) == 1;
                //@"INSERT INTO [Candy]([Name], [type])
                //            VALUES(@Name, @Type)";
            }
        }
コード例 #11
0
        public IActionResult Add(AddCandyDto newAddCandyDto)
        {
            var newCandy = new Candy
            {
                CandyId            = 1,
                Name               = newAddCandyDto.Name,
                Category           = newAddCandyDto.Category,
                YearsSinceCreation = newAddCandyDto.YearsSinceCreation
            };

            var candyThatGotCreated = _repo.AddCandy(newCandy);

            return(Created($"api/candy/{candyThatGotCreated.Name}", candyThatGotCreated));
        }
コード例 #12
0
        public bool AddCandy(AddCandyDto newCandy)
        {
            using (var db = new SqlConnection(_connectionString))
            {
                var sql = @"INSERT INTO [dbo].[Candy]
                                        ([Name]
                                        ,[CandyTypeId])
                           VALUES
                                        (@Name
                                        ,@CandyTypeId)";

                return(db.Execute(sql, newCandy) == 1);
            }
        }
コード例 #13
0
        public bool AddCandy(AddCandyDto newCandy)
        {
            using (var db = new SqlConnection(_connectionString))
            {
                var sql = @"INSERT INTO [dbo].[Candy]
                           ([Name]
                           ,[Manufacturer]
                           ,[Category])
                     VALUES
                           (@name
                           ,@manufacturer
                           ,@category)";

                return(db.Execute(sql, newCandy) == 1);
            }
        }
コード例 #14
0
 public bool AddCandy(AddCandyDto newCandy)
 {
     using (var db = new SqlConnection(_connectionString))
     {
         throw new NotImplementedException();
         //var sql = @"INSERT INTO [dbo].[Candy]
         //                       ([Name]
         //                       ,[Flavor]
         //                       ,[Price])
         //                    output inserted.*
         //                    VALUES
         //                       (@name
         //                       ,@flavor
         //                       ,@price)";
         //return db.QueryFirst<Candy>(sql, newCandy);
     }
 }
コード例 #15
0
        public Candy AddCandy(AddCandyDto newCandy)
        {
            using (var db = new SqlConnection(_connectionString))
            {
                var sql = @"insert into [candy]
                                ([name],
                                [manufacturer],
                                [category])
                                output inserted.*
                                values
                                (@name,
                                @manufacturer,
                                @category)";

                var candy = db.QueryFirst <Candy>(sql, newCandy);
                return(candy);
            }
        }
コード例 #16
0
        public bool AddCandy(AddCandyDto newCandy)
        {
            using (var db = new SqlConnection(_connectionString))
            {
                var addCandy = @"insert into [Candy]
                                    ([Name]) 
                                    output inserted.* 
                                    values 
                                    (@name)";

                var parameters = new {
                    name = newCandy.Name
                };

                var rowsAffected = db.Execute(addCandy, parameters);
                return(rowsAffected == 1);
            }
        }
コード例 #17
0
        public bool AddCandy(AddCandyDto newCandy)
        {
            using var db = new SqlConnection(_connectionString);
            var sql = @"INSERT INTO [dbo].[Candy]
                                       ([Name]
                                       ,[Type]
                                       ,[TypeId]
                                       ,[Price]
                                       ,[UserId])
                                 VALUES
                                       (
                                       @name
                                       ,@type
                                       ,@typeId
                                       ,@price
                                       ,@UserId)";

            return(db.Execute(sql, newCandy) == 1);
        }
コード例 #18
0
        public bool AddCandy(AddCandyDto newCandy)
        {
            using (var db = new SqlConnection(_connectionString))
            {
                var sql = @"INSERT INTO [Candy]
                                           ([Name]
                                           ,[Texture])
	                                 output inserted.*
                                     VALUES
                                           (@name
                                           ,@texture)";

                //var parameters = new
                //{
                //    candyName = newCandy.Name,
                //    candyType = newCandy.Type
                //};
                return(db.Execute(sql, newCandy) == 1);
            }
        }
コード例 #19
0
        public bool AddCandy(AddCandyDto newCandy)
        {
            using (var db = new SqlConnection(_connectionString))
            {
                var sql =
                    @"INSERT INTO [Candy]
                                           ([Name]
                                           ,[YearsOfExperience]
                                           ,[Specialty])
	                                 output inserted.*
                                     VALUES
                                           (@name
                                           ,@yearsOfExperience
                                           ,@specialty)";

                return(db.QueryFirst <Candy>(sql, newCandy));

                //33:24
            }
        }
コード例 #20
0
        public bool AddCandy(AddCandyDto newCandy)
        {
            using (var db = new SqlConnection(_connectionString))
            {
                //check if candy exists

                //var candyCheck = @"SELECT * from Candy
                //WHERE [Name] = @name";

                // if not, add to candy repo

                // then add to UserCandy

                var sqlQuery = @"Insert into [dbo].[Candy]
                               ([Name]
                                [Id)
                               Values(
                                 @name
                                  @id)";

                return(db.Execute(sqlQuery, newCandy) == 1);
            };
        }
コード例 #21
0
 public bool AddCandy(AddCandyDto newCandy)
 {
     throw new NotImplementedException();
 }
コード例 #22
0
 public Candy Add(AddCandyDto newCandy)
 {
     return(_repo.AddCandy(newCandy));
 }
コード例 #23
0
 public void Add(AddCandyDto newCandy)
 {
     _repo.AddCandy(newCandy);
 }