Example #1
0
 public ActionResult Create(Company company)
 {
     using (var cm = new CompanyManager())
     {
         company = cm.Create(company);
     }
     return(RedirectToAction("List"));
 }
Example #2
0
        public void GetTest()
        {
            var manager = new CompanyManager();
            var company = new Company {
                Id = Guid.NewGuid(), Clients = new List <Client>(), Name = "test name"
            };

            manager.Create(company);

            var retutnCompany = manager.Get(company.Id);

            Assert.IsNotNull(retutnCompany);
        }
Example #3
0
        public void Test_CompanyMgr_CompanyUpdate()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try {
                var options = new DbContextOptionsBuilder <HOSContext>()
                              .UseSqlite(connection)
                              .Options;

                using (var context = new HOSContext(options))
                {
                    context.Database.EnsureCreated();
                }

                using (var context = new HOSContext(options))
                {
                    ICompanyManager companyMgr = new CompanyManager(new Repository(context));

                    var company = new Company()
                    {
                        CompanyCode = "FCT001",
                        CompanyName = "First Choice Transport",
                        DOT_Number  = "951560",
                        MC_Number   = "MC-407377",
                        CreatedBy   = "admin",
                        CreatedOn   = DateTime.Now,
                        UpdatedBy   = "admin",
                        UpdatedOn   = DateTime.Now
                    };

                    companyMgr.Create(company);
                    companyMgr.SaveChanges();

                    var test = companyMgr.GetCompany(c => c.CompanyCode == "FCT001");
                    Assert.NotNull(test);
                    Assert.Equal(company.CompanyCode, test.CompanyCode);

                    company.CompanyName = "First Choice Transport, Inc";
                    company.UpdatedOn   = DateTime.Now;
                    companyMgr.Update(company);
                    companyMgr.SaveChanges();

                    test = companyMgr.GetCompany(c => c.CompanyCode == "FCT001");
                    Assert.Equal("First Choice Transport, Inc", test.CompanyName);
                }
            } finally {
                connection.Close();
            }
        }
Example #4
0
        public void CreateTest()
        {
            var manager = new CompanyManager();
            var company = new Company {
                Id = Guid.NewGuid(), Clients = new List <Client>(), Name = "test name", ChildCompanies = new List <Company> {
                    new Company {
                        Id = Guid.NewGuid(), Name = "test child"
                    }
                }
            };
            var actual = manager.Create(company);

            Assert.IsTrue(actual);
        }
Example #5
0
        public void GetAllTest()
        {
            var manager = new CompanyManager();
            var company = new Company {
                Id = Guid.NewGuid(), Clients = new List <Client>(), Name = "test name"
            };

            manager.Create(company);

            var actual = manager.GetAll();

            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Count() > 0);
        }
        public IHttpActionResult Post(Company company)
        {
            try
            {
                var Mngr = new CompanyManager();
                Mngr.Create(company);

                ApiResponse ApiResp = new ApiResponse
                {
                    Message = "Compañía registrada exitosamente"
                };

                return(Ok(ApiResp));
            }
            catch (BusinessException bex)
            {
                return(InternalServerError(new Exception(bex.ExceptionId + "-" + bex.AppMessage.Message)));
            }
        }
Example #7
0
        public void CreateCompanyTest()
        {
            var company = new Company
            {
                Address = "460 South Marion pkwy apt 1402",
                City    = "Denver",
                Email   = "*****@*****.**",
                Name    = "Third Company",
                Phone   = "815-919-5371",
                State   = "CO",
                Zip     = "80209"
            };

            using (var cm = new CompanyManager())
            {
                company = cm.Create(company);
            }

            Assert.IsTrue(company.ID > 0);
        }