public async System.Threading.Tasks.Task <IActionResult> Info(int idi)
 {
     Models.Companies s = null;
     try
     {
         using (var con = new SqlConnection(configuration.GetConnectionString("DefaultConnection")))
         {
             con.Open();
             SqlCommand    CompaniesQuery = new SqlCommand("SELECT  Name,CreateDate,CreatorName,companies.id,worker,former From Companies INNER JOIN Worker ON worker.CompanyID=Companies.id WHERE companies.id = " + idi + ";", con);
             var           Read           = CompaniesQuery.ExecuteReader();
             List <string> employ         = new List <string>();
             while (Read.Read())
             {
                 s = new Models.Companies(Read.GetInt32(3), Read[0].ToString(), employ, Read[1].ToString(), Read[2].ToString(), Read.GetInt32(5));
                 if (Read[4] != null)
                 {
                     s.workers.Add(Read[4].ToString());
                 }
             }
             Read.Close();
             CompaniesQuery.Dispose();
             con.Close();
         }
     }
     catch (IOException) { }
     return(View(s));
 }
Beispiel #2
0
 public async System.Threading.Tasks.Task <IActionResult> MCompanyAsync(int id)
 {
     Models.Companies s = null;
     using (var con = new SqlConnection(configuration.GetConnectionString("DefaultConnection")))
     {
         con.Open();
         SqlCommand    CompaniesQuery = new SqlCommand("SELECT companies.id,worker,former From Companies INNER JOIN Worker ON worker.CompanyID=Companies.id WHERE companies.id = " + id + "AND Worker ='" + User.Identity.Name + "';", con);
         var           Read           = CompaniesQuery.ExecuteReader();
         List <string> employ         = new List <string>();
         while (Read.Read())
         {
             if (Read.GetInt32(0) == null)
             {
                 return(View("You do not have permission"));
             }
             else if (Read.GetInt32(2) == 0)
             {
                 return(RedirectToAction("Info", "InfoCompany", new { idi = id }, null));
             }
         }
         Read.Close();
         CompaniesQuery.Dispose();
         con.Close();
     }
     try
     {
         using (var con = new SqlConnection(configuration.GetConnectionString("DefaultConnection")))
         {
             con.Open();
             SqlCommand    CompaniesQuery = new SqlCommand("SELECT  Name,CreateDate,CreatorName,companies.id,worker,former From Companies INNER JOIN Worker ON worker.CompanyID=Companies.id WHERE companies.id = " + id + ";", con);
             var           Read           = CompaniesQuery.ExecuteReader();
             List <string> employ         = new List <string>();
             while (Read.Read())
             {
                 s = new Models.Companies(Read.GetInt32(3), Read[0].ToString(), employ, Read[1].ToString(), Read[2].ToString(), Read.GetInt32(5));
                 if (Read[4] != null)
                 {
                     s.workers.Add(Read[4].ToString());
                 }
             }
             Read.Close();
             CompaniesQuery.Dispose();
             con.Close();
         }
     }
     catch (IOException) { }
     return(View(s));
 }
Beispiel #3
0
        public ActionResult NewCompany(CompaniesNew formData)
        {
            var newComp     = new Models.Companies();
            var currentUser = Database.Session.Query <Models.User>()
                              .FirstOrDefault(u => u.Username == HttpContext.User.Identity.Name);

            newComp.Companyname       = formData.companyMame;
            newComp.Address           = formData.address;
            newComp.belongsToUser     = currentUser;
            newComp.Faxnumber         = formData.faxNumber;
            newComp.Phonenumber       = formData.phoneNumber;
            newComp.Iban              = formData.IBAN;
            newComp.Taxadministration = formData.TaxAdministration;
            newComp.inBalance         = formData.inBalance;
            newComp.outBalance        = formData.outBalance;

            Database.Session.Save(newComp);
            Database.Session.Flush();

            return(RedirectToRoute("Firmalar", new { id = currentUser.Id }));
        }
        public IHttpActionResult PostCompanies(int id)
        {
            var compInDb = _context.Companies.SingleOrDefault(t => t.CompanyId == id);

            if (compInDb != null)
            {
                compInDb.CompanyName = HttpContext.Current.Request.Params["CompanyName"];
                compInDb.Email       = HttpContext.Current.Request.Params["Email"];
                compInDb.Phone       = HttpContext.Current.Request.Params["Phone"];
            }
            else
            {
                var companies = new Models.Companies();

                companies.CompanyName = HttpContext.Current.Request.Params["CompanyName"];
                companies.Email       = HttpContext.Current.Request.Params["Email"];
                companies.Phone       = HttpContext.Current.Request.Params["Phone"];

                _context.Companies.Add(companies);
            }

            _context.SaveChanges();
            return(Ok());
        }