Exemple #1
0
        public void GetXmlTest()
        {
            string expected = @"<?xml version=""1.0"" encoding=""utf-8""?>
<function controlid=""unittest"">
    <create>
        <CONTRACT>
            <CONTRACTID>CT1234</CONTRACTID>
            <CUSTOMERID>C1234</CUSTOMERID>
            <NAME>Contract name</NAME>
            <BEGINDATE>01/01/2017</BEGINDATE>
            <ENDDATE>12/31/2017</ENDDATE>
            <BILLINGFREQUENCY>Monthly</BILLINGFREQUENCY>
            <TERMNAME>N30</TERMNAME>
        </CONTRACT>
    </create>
</function>";

            ContractCreate record = new ContractCreate("unittest")
            {
                ContractId       = "CT1234",
                CustomerId       = "C1234",
                ContractName     = "Contract name",
                BeginDate        = new DateTime(2017, 01, 01),
                EndDate          = new DateTime(2017, 12, 31),
                BillingFrequency = "Monthly",
                PaymentTerm      = "N30",
            };

            this.CompareXml(expected, record);
        }
        public void ContractController_PostContract_ShouldReturnOk()
        {
            var contract = new ContractCreate {
            };
            var result   = _controller.Post(contract);

            Assert.AreEqual(1, _mockService.CallCount);
            Assert.IsInstanceOfType(result, typeof(OkResult));
        }
Exemple #3
0
        private void CheckIfContractExists(ApplicationDbContext ctx, ContractCreate model)
        {
            var entity =
                ctx
                .Contracts
                .Single(e => e.DeveloperId == model.DeveloperId && e.IsActive == true);

            if (entity != null)
            {
                throw new Exception("The developer you entered already has an existing contract");
            }
        }
Exemple #4
0
        private void CheckIfTeamExists(ApplicationDbContext ctx, ContractCreate model)
        {
            var entity =
                ctx
                .Teams
                .SingleOrDefault(e => e.TeamId == model.TeamId);

            if (entity == null)
            {
                throw new ArgumentNullException("The team you entered does not exist in the system.");
            }
        }
Exemple #5
0
        public async Task <ActionResult <Contract> > AddContract(ContractCreate contractCreate)
        {
            var contract = _mapper.Map <Contract>(contractCreate);

            _contractRepository.AddContract(contract);

            if (await _contractRepository.SaveAllAsync())
            {
                return(Ok(contract));
            }

            return(BadRequest("Failed to create Customer"));
        }
        public IHttpActionResult Post(ContractCreate contract)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            if (!_contractService.CreateContract(contract))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
Exemple #7
0
        public bool CreateNote(ContractCreate model)
        {
            var entity =
                new Contracts()
            {
                OwnerID      = _userId,
                ContractID   = model.ContractID,
                ContractName = model.Name,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Contracts.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public bool CreateContract(ContractCreate model)
        {
            var entity =
                new Contract()
            {
                OwnerId  = _userId,
                ClientId = model.ClientId,
                MowerId  = model.MowerId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Contracts.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public bool CreateContract(ContractCreate model)
        {
            var entity =
                new Contract()
            {
                DeveloperId = model.DeveloperId,
                TeamId      = model.TeamId,
                EndDate     = model.EndDate,
                StartDate   = model.StartDate
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Contracts.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Create(ContractCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateContractService();

            if (service.CreateContract(model))
            {
                TempData["SaveResult"] = "Your contract was created.";
                return(RedirectToAction("Index"));
            }
            ;
            return(View(model));
        }
Exemple #11
0
        public bool CreateContract(ContractCreate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                CheckIfDeveloperExists(ctx, model);
                CheckIfTeamExists(ctx, model);
                CheckIfContractExists(ctx, model);

                var entity =
                    new Contract()
                {
                    DeveloperManagerId = _userId,
                    DeveloperId        = model.DeveloperId,
                    TeamId             = model.TeamId,
                    IsActive           = true
                };

                ctx.Contracts.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemple #12
0
 public bool CreateContract(ContractCreate model)
 {
     CallCount++;
     return(ReturnValue);
 }