public static int Add(CustModel customer)
        {
            using (SqlConnection connection = new SqlConnection(GetConnectionString()))
            {
                int result;

                using (SqlCommand command = new SqlCommand("", connection))
                {
                    command.Parameters.AddWithValue("@ID", customer.ID);
                    command.Parameters.AddWithValue("@CustID", customer.CustomerID);
                    command.Parameters.AddWithValue("@Name", customer.Name);
                    command.Parameters.AddWithValue("@Surname", customer.Surname);
                    command.Parameters.AddWithValue("@Address", customer.Address);
                    command.Parameters.AddWithValue("@Town", customer.Town);
                    command.Parameters.AddWithValue("@Mail", customer.Mail);
                    command.Parameters.AddWithValue("@IsActive", customer.IsActive);
                    command.Parameters.AddWithValue("@Rating", customer.Rating);
                    command.Parameters.AddWithValue("@Username", customer.Username);
                    command.Parameters.AddWithValue("@Password", customer.Password);
                    command.Parameters.AddWithValue("@Country", customer.Country);
                    command.Parameters.AddWithValue("@DOB", customer.DOB);

                    connection.Open();

                    result = command.ExecuteNonQuery();

                    connection.Close();
                }

                return(result);
            }
        }
        public IHttpActionResult AddEmpDetails(CustModel cust)
        {
            string password = cust.Pass;
            string Name     = cust.Name;
            string value;
            var    Affirm = new AffirmModel();

            using (LinqToDBDataContext con = new LinqToDBDataContext())
            {
                var query = (from p in con.Customers
                             where p.CustomerName == Name
                             select p.CustomerPassword).FirstOrDefault();
                value = query.ToString();
                if (value == password)
                {
                    Affirm.AffirmLogIn = true;
                }
                else
                {
                    Affirm.AffirmLogIn = false;
                }
                var query1 = (from p in con.Customers
                              where p.CustomerName == Name
                              select p.CustomerID).FirstOrDefault();
                value         = query1.ToString();
                Affirm.CustId = value;

                var json = new JavaScriptSerializer().Serialize(Affirm);
                return(new RawJsonActionResult(json));
            }
        }
Example #3
0
        public static int CreateCustomer(int id, string name, string surname, string address,
                                         string town, string country, string mail, DateTime dob, bool status,
                                         string username, string password, int rating)
        {
            CustModel customer = new CustModel
            {
                ID       = id, Name = name, Surname = surname, Address = address,
                Town     = town, Country = country, Mail = mail, DOB = dob,
                IsActive = status, Username = username, Password = password, Rating = rating
            };

            string sql = @"INSERT INTO [dbo].[CustomerDB]
           (
           [Name]
           ,[Surname]
           ,[Address]
           ,[Town]
           ,[Country]
           ,[Mail]
           ,[DOB]
           ,[IsActive]
           ,[Username]
           ,[Password]
           ,[Rating])
     VALUES
           (
           @Name,
           @Surname,
           @Address,
           @Town,
           @Country,
           @Mail,
           @DOB,
           @IsActive,
           @Username,
           @Password,
           @Rating)";

            return(SQLDataAccess.SaveData <CustModel>(sql, customer));
        }