public bool AddPlate(Plate plate)
        {
            if (plate == null)
            {
                return(false);
            }

            _plates.Add(plate);
            return(true);
        }
Example #2
0
        const string ConnectionString = @"Server=(localdb)\MSSQLLocalDB;Database=EmployeeDbDev;Trusted_Connection=True;MultipleActiveResultSets=true";//"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=myTestDB;Data Source=ANKIT-HP\\SQLEXPRESS";

        public int AddPlate(Plate plate)
        {
            if (plate == null)
            {
                return(0);
            }

            try
            {
                using (var connection = new SqlConnection(ConnectionString))
                {
                    var insertedPlate = connection.QuerySingle <Plate>("spAddPlate",
                                                                       new{ plate.Name, plate.MinCharacters, plate.MaxCharacters },
                                                                       commandType: System.Data.CommandType.StoredProcedure);

                    return(insertedPlate.Id);
                }
            }
            catch (Exception ex)
            {
            }

            return(-1);
        }