Ejemplo n.º 1
0
        public int Delete(Company company)
        {
            companyDao.Delete(company);

            var user = Get(company.Id);

            if (user == null)
                return 1;

            return 0;
        }
        public List<Entity.Company> List(string name)
        {
            int id = int.Parse(Session[sessionName].ToString());
            UserBO userBO = new UserBO();
            User user = userBO.Get(id);

            Entity.Company company = new Entity.Company();
            company.Name = name;
            company.ParentId = user.CompanyId;

            return companyBO.List(company);
        }
Ejemplo n.º 3
0
 public int Save(Company company)
 {
     if (Get(company.Id) == null)
     {
         //Create company
         return Insert(company);
     }
     else
     {
         //Update company
         return Update(company);
     }
 }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int id = int.Parse(Session[sessionName].ToString());
            UserBO userBO = new UserBO();
            User user = userBO.Get(id);

            Entity.Company company = new Entity.Company();
            company.Id = user.CompanyId;

            company = companyBO.Get(user.CompanyId);

            if (company.LevelId == 4)
                Response.Redirect("index.aspx");
        }
Ejemplo n.º 5
0
 public ActionResult EditCompany(Company company)
 {
     ViewBag.Title = "Edit Company";
     Console.WriteLine(company.Id + ";" + company.Name + ";" + company.Description);
     ViewBag.postInfo      = "Company saved successfuly";
     ViewBag.postInfoClass = "alert-success";
     if (!ModelState.IsValid)
     {
         //ViewBag.Errors.Name=ModelState["Name"].Errors[0].ErrorMessage+"\n";
         //ViewBag.postInfoClass = "alert-danger";
         return(View(company));
     }
     using (var dao = new Dao.Dao())
     {
         dao.UpdateCompany(company);
     }
     return(View("Saved"));
 }
        private void Validate()
        {
            //Level
            int id = int.Parse(Session[sessionName].ToString());
            UserBO userBO = new UserBO();
            User user = userBO.Get(id);

            Entity.Company company = new Entity.Company();
            company.Id = user.CompanyId;

            company = companyBO.Get(user.CompanyId);

            if (company.LevelId == 4)
                lblCompany.Visible = false;

            //Rol
            if (user.RolId > 2)
            {
                lblCompany.Visible = false;
                lblUser.Visible = false;
            }

            if (user.RolId == 2)
            {
                lblCompany.Visible = false;
            }

            if (user.RolId == -1)
            {
                lblManage.Visible = true;
                lblHome.Visible = false;
                lblCompany.Visible = false;
                lblUser.Visible = false;
            }
            else
            {
                lblManage.Visible = false;
            }
        }
        public bool Save(string nit, string name, decimal document, string username, string password)
        {
            Entity.Company company = new Entity.Company();
            CompanyBO companyBo = new CompanyBO();

            int id = int.Parse(Session[sessionName].ToString());
            UserBO userBO = new UserBO();
            User user = userBO.Get(id);

            var parentCompany = companyBo.Get(user.CompanyId);

            company.Id = nit;
            company.Name = name;
            company.CreationDate = DateTime.Now;
            company.LevelId = parentCompany.LevelId + 1;
            company.ParentId = parentCompany.Id;
            company.CreationUser = id;
            company.ManagerId = document;
            companyBo.Save(company);

            var manager = userBO.Get(document);

            if (manager == null)
            {
                manager = new User();
            }

            manager.CompanyId = nit;
            manager.Document = document;
            manager.Name = username;
            manager.RolId = 1;
            manager.Password = password;

            userBO.Save(manager);

            return true;
        }
Ejemplo n.º 8
0
 public Entity.Company InsertCompany(Entity.Company v)
 {
     v = Context.Companies.Add(v);
     Context.SaveChanges();
     return(v);
 }
Ejemplo n.º 9
0
 public Entity.Company UpdateCompany(Entity.Company c)
 {
     Context.Companies.AddOrUpdate(c);
     Context.SaveChanges();
     return(c);
 }
Ejemplo n.º 10
0
 public int Update(Company user)
 {
     return ExecuteScalar("CompanyUpdate", user);
 }
Ejemplo n.º 11
0
 public List<Company> List(Company agent)
 {
     return Execute<Company>("CompanyList", agent);
 }
Ejemplo n.º 12
0
 public int Insert(Company company)
 {
     return ExecuteScalar("CompanyInsert", company);
 }
Ejemplo n.º 13
0
 public Company Get(string id)
 {
     Company company = new Company();
     company.Id = id;
     return Get<Company>("CompanyGet", company);
 }
Ejemplo n.º 14
0
 public void Delete(Company company)
 {
     Execute<Company>("CompanyDelete", company);
 }
 public int Delete(string id)
 {
     Entity.Company company = new Entity.Company();
     company.Id = id;
     return companyBO.Delete(company);
 }
Ejemplo n.º 16
0
 private int Update(Company company)
 {
     return companyDao.Update(company);
 }
Ejemplo n.º 17
0
 private int Insert(Company company)
 {
     return companyDao.Insert(company);
 }
Ejemplo n.º 18
0
 public List<Company> List(Company agent)
 {
     return companyDao.List(agent);
 }