public ActionResult Edit(int id)
        {
            if (User.Identity.Name == "")
            {
                return(RedirectToAction("ErrorLogin", "Home"));
            }
            PMOrganisation organisation = DAOrganisation.GetOrganisationById(id);

            ViewBag.Organisation = organisation;
            ViewBag.Id           = id;
            return(View(organisation));
        }
 public ActionResult Edit(PMOrganisation organisation, int id)
 {
     if (User.Identity.Name == "")
     {
         return(RedirectToAction("ErrorLogin", "Home"));
     }
     if (ModelState.IsValid)
     {
         DAOrganisation.UpdateOrganisation(id, organisation);
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("Edit", new { organisation = organisation, id = id }));
 }
 public ActionResult NewOrganisation(PMOrganisation organisation)
 {
     if (User.Identity.Name == "")
     {
         return(RedirectToAction("ErrorLogin", "Home"));
     }
     if (ModelState.IsValid)
     {
         if (DAOrganisation.InsertOrganisation(organisation) < 0)
         {
             return(View(organisation));
         }
         return(RedirectToAction("Index"));
     }
     return(View(organisation));
 }
Exemplo n.º 4
0
        public static PMOrganisation GetOrganisationById(int id)
        {
            string         sql          = "SELECT * FROM Organisations WHERE ID=@ID";
            DbParameter    par1         = Database.AddParameter("AdminDB", "@ID", id);
            DbDataReader   reader       = Database.GetData(Database.GetConnection("AdminDB"), sql, par1);
            PMOrganisation organisation = new PMOrganisation();

            while (reader.Read())
            {
                organisation.Id               = (int)reader["ID"];
                organisation.Login            = reader["Login"].ToString();
                organisation.Password         = reader["Password"].ToString();
                organisation.DbName           = reader["DbName"].ToString();
                organisation.DbLogin          = reader["DbLogin"].ToString();
                organisation.DbPassword       = reader["DbPassword"].ToString();
                organisation.OrganisationName = reader["OrganisationName"].ToString();
                organisation.Address          = reader["Address"].ToString();
                organisation.Email            = reader["Email"].ToString();
                organisation.Phone            = reader["Phone"].ToString();
            }
            return(organisation);
        }