Ejemplo n.º 1
0
        public string UpdateCompany(int companyId, Company newCompany)
        {
            var company = (from c in db.companies
                           where c.id == companyId
                           select c).First();

            company.name = newCompany.Name;

            ZipCodeApiController zipControl = new ZipCodeApiController();


            var zip = zipControl.PullZipCode(newCompany);



            company.cvr                   = Int32.Parse(newCompany.CVR);
            company.phone                 = Int32.Parse(newCompany.Phone);
            company.email                 = newCompany.Email;
            company.ceo                   = newCompany.CEO;
            company.startup_date          = newCompany.StartUpDate;
            company.is_activ              = newCompany.Active;
            company.description           = newCompany.ReasonNotActive;
            company.financial_report      = newCompany.FinancialReport;
            company.advertising_protected = newCompany.AdverticingProtected;
            company.empoye_count          = newCompany.EmployeeCount;
            company.address               = newCompany.Address;
            company.zip_code_id           = zip.Id;
            try
            {
                db.SubmitChanges();
                return(newCompany.Name + " opdateret.");
            }
            catch (Exception e)
            {
                return("Operationen mislykkedes. Kontakt IT-Support med følgende fejlbesked: " + e.Message);
            }
        }
Ejemplo n.º 2
0
        public string UpdateCompany(int companyId, Company newCompany)
        {
            var company = (from c in db.companies
                           where c.id == companyId
                           select c).First();

            company.name = newCompany.Name;

            ZipCodeApiController zipControl = new ZipCodeApiController();

            var zip = zipControl.PullZipCode(newCompany);

            company.cvr = Int32.Parse(newCompany.CVR);
            company.phone = Int32.Parse(newCompany.Phone);
            company.email = newCompany.Email;
            company.ceo = newCompany.CEO;
            company.startup_date = newCompany.StartUpDate;
            company.is_activ = newCompany.Active;
            company.description = newCompany.ReasonNotActive;
            company.financial_report = newCompany.FinancialReport;
            company.advertising_protected = newCompany.AdverticingProtected;
            company.empoye_count = newCompany.EmployeeCount;
            company.address = newCompany.Address;
            company.zip_code_id = zip.Id;
            try
            {
                db.SubmitChanges();
                return newCompany.Name + " opdateret.";
            }
            catch (Exception e)
            {
                return "Operationen mislykkedes. Kontakt IT-Support med følgende fejlbesked: " + e.Message;
            }
        }