public CompanyListViewModel(Company company )
 {
     this.ID = company.ID;
     this.Name = company.Name;
     this.Market = company.Market;
     this.Mail = company.Mail;
     this.Logo = company.Logo;
 }
 public CompanyDetailViewModel(Company company)
 {
     this.ID = company.ID;
     this.Name = company.Name;
     this.Market = company.Market;
     this.Mail = company.Mail;
     this.Logo = company.Logo;
     competitors = new Dictionary<int, string>();
 }
Esempio n. 3
0
        public async Task <IActionResult> GetById(int id)
        {
            Model.Company entity = await dataAccess.FindByIdAsync(id);

            if (entity == null)
            {
                return(NotFound());
            }

            return(Ok(Mapper.Map <DTO.Company>(entity)));
        }
Esempio n. 4
0
        public async Task <IActionResult> Post([FromBody] DTO.Company company)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Model.Company entity = Mapper.Map <Model.Company>(company);
            entity = await dataAccess.AddAsync(entity);

            return(Created($"api/Company/{entity.Id}", Mapper.Map <DTO.Company>(entity)));
        }
Esempio n. 5
0
        public async Task <IActionResult> Delete(int id)
        {
            Model.Company entity = await dataAccess.FindByIdAsync(id);

            if (entity == null)
            {
                return(NotFound());
            }

            await dataAccess.DeleteAsync(entity);

            return(Accepted(Mapper.Map <DTO.Company>(entity)));
        }
Esempio n. 6
0
        public async Task <IActionResult> Put(int id, [FromBody] DTO.Company company)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Model.Company entity = await dataAccess.FindByIdAsync(id);

            if (entity == null)
            {
                return(NotFound());
            }

            entity = await dataAccess.EditAsync(Mapper.Map(company, entity));

            return(Accepted(Mapper.Map <DTO.Company>(entity)));
        }
 public bool CreateCompany(Company companyfromVM)
 {
     Company company;
     bool succes = true;
     try
     {
         using (Model1Container context = new Model1Container())
         {
             company = context.Company.Add(companyfromVM);
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         succes = false;
     }
     return succes;
 }
Esempio n. 8
0
        static void Main(string[] args)
        {
            Company c = new Company(new MonitorLockExpenses());

            c.Name = "Company 1";

            c.Expenses.Deposit(1000);
            c.Expenses.Deposit(1500);
            c.Expenses.Deposit(500);

            Thread t1 = new Thread(() =>
            {
                c.Expenses.AddInvoice(new Invoice()
                {
                    Value = 100
                });
            });

            t1.Start();

            Thread t2 = new Thread(() =>
            {
                c.Expenses.AddInvoice(new Invoice()
                {
                    Value = 200
                });
            });

            t2.Start();

            t1.Join();
            t2.Join();

            Console.WriteLine("Balance: {0}", c.Expenses.Balance);
            Console.ReadLine();
        }
 public void Update(Company entity)
 {
     Company company = this.Get(entity.CompanyID);
     company.CompanyName = entity.CompanyName;
     this.CompanyRepository.Update(company);
 }
 public object Save(Company entity)
 {
     return this.CompanyRepository.Save(entity);
 }
        public ActionResult SaveCompany(Company company)
        {
            CompanyManager.Save(company);

            return RedirectToAction("Index", "Home");
        }
 public void Save()
 {
     Company company = new Company();
     company.CompanyName = "刘冬公司";
     companyManager.Save(company);
 }
 public void Update(Company entity)
 {
     this.CompanyRepository.Update(entity);
 }
Esempio n. 14
0
 public bool UpdateCompany(Company companyfromVM)
 {
     Company company;
     bool succes = true;
     try
     {
         using (Model1Container context = new Model1Container())
         {
             company = context.Company.Find(companyfromVM.ID);
             context.Entry(company).CurrentValues.SetValues(companyfromVM);
             context.SaveChanges();
         }
     }
     catch (Exception e)
     {
         succes = false;
     }
     return succes;
 }