Inheritance: BaseEntity
        //
        public int AddCompany(Company company)
        {
            using (var conn = new SqlConnection(PrescienceRxConnectionString))
            {
                conn.Open();

                using (var cmd = new SqlCommand(AddCompanySp, conn))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;

                    cmd.Parameters.Add("@CompanyName", System.Data.SqlDbType.VarChar);
                    cmd.Parameters["@CompanyName"].Value = company.CompanyName;

                    cmd.Parameters.Add("@Description", System.Data.SqlDbType.VarChar);
                    cmd.Parameters["@Description"].Value = company.Description;

                    cmd.Parameters.Add("@CreatedBy", System.Data.SqlDbType.Int);
                    cmd.Parameters["@CreatedBy"].Value = company.CreatedBy;

                    cmd.Parameters.Add("@UpdatedBy", System.Data.SqlDbType.Int);
                    cmd.Parameters["@UpdatedBy"].Value = company.UpdatedBy;

                    int i= Convert.ToInt16(cmd.ExecuteScalar());
                    if (i > 0)
                    {
                        cmd.CommandText = AssignCompanyModuleSp;
                        cmd.Parameters.Clear();

                        cmd.Parameters.Add("@CompanyId", System.Data.SqlDbType.Int);
                        cmd.Parameters["@CompanyId"].Value = i;

                        cmd.Parameters.Add("@ModuleId", System.Data.SqlDbType.Int);
                        foreach (var item in company.LstModules)
                        {
                            cmd.Parameters["@ModuleId"].Value = item;
                            cmd.ExecuteNonQuery();
                        }
                    }
                    return i;
                }

            }
        }
        //
        public bool UpdateCompany(Company company)
        {
            using (var conn = new SqlConnection(PrescienceRxConnectionString))
            {
                conn.Open();

                using (var cmd = new SqlCommand(UpdateCompanySp, conn))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;

                    cmd.Parameters.Add("@CompanyId", System.Data.SqlDbType.Int);
                    cmd.Parameters["@CompanyId"].Value = company.CompanyId;

                    cmd.Parameters.Add("@CompanyName", System.Data.SqlDbType.VarChar);
                    cmd.Parameters["@CompanyName"].Value = company.CompanyName;

                    cmd.Parameters.Add("@Description", System.Data.SqlDbType.VarChar);
                    cmd.Parameters["@Description"].Value = company.Description;

                    cmd.Parameters.Add("@UpdatedBy", System.Data.SqlDbType.Int);
                    cmd.Parameters["@UpdatedBy"].Value = company.UpdatedBy;

                    cmd.Parameters.Add("@IsActive", System.Data.SqlDbType.Bit);
                    cmd.Parameters["@IsActive"].Value = company.IsActive;

                    bool b = cmd.ExecuteNonQuery() > 0;
                    if (b)
                    {
                        cmd.CommandText = "Delete from dbo.CompanyModules WHERE companyId=" + company.CompanyId;
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.Clear();
                        cmd.ExecuteNonQuery();

                        cmd.CommandText = AssignCompanyModuleSp;
                        cmd.CommandType = CommandType.StoredProcedure;

                        cmd.Parameters.Add("@CompanyId", System.Data.SqlDbType.Int);
                        cmd.Parameters["@CompanyId"].Value = company.CompanyId;

                        cmd.Parameters.Add("@ModuleId", System.Data.SqlDbType.Int);
                        foreach (var item in company.LstModules)
                        {
                            cmd.Parameters["@ModuleId"].Value = item;
                            cmd.ExecuteNonQuery();
                        }
                    }
                    return b;
                }
            }
        }
        //
        public Company GetCompnay(int companyId)
        {
            Company company = null;
            using (var conn = new SqlConnection(PrescienceRxConnectionString))
            {
                conn.Open();

                using (var cmd = new SqlCommand(GetCompanyByIdSp, conn))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;

                    cmd.Parameters.Add("@CompanyId", System.Data.SqlDbType.Int);
                    cmd.Parameters["@CompanyId"].Value = companyId;

                    using (var myReader = cmd.ExecuteReader())
                    {
                        try
                        {
                            if (myReader.HasRows)
                            {
                                myReader.Read();
                                company = new Company(myReader);
                                AdminRepository admrep = new AdminRepository();
                                List<Module> modules = admrep.GetModulesByCompany(Convert.ToInt32(myReader["CompanyId"]));
                                company.LstModules = new List<int>();
                                foreach (var item in modules)
                                {
                                    company.LstModules.Add(item.ModuleId);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            // TODO Logg Error here
                        }
                    }
                }

            }
            return company;
        }