示例#1
0
        public ActionResult <IEnumerable <MClient> > Get()
        {
            //return Ok(new[] { new MClient { FirstName = "Jhon", LastName = "Doe", CarType = "Toyota", LicensePN = "KGB-456", Description = "oil change", StartingDate = DateTime.Now } });

            var mclients = MClientRepository.GetMClients();

            return(Ok(mclients));
        }
示例#2
0
        public void GetMclient_WithValidArgument_ClientListNotEmpty()
        {
            // Arrange
            var aclient = MClientRepository.GetMClients().ToList();

            //Assert
            Assert.NotEmpty(aclient);
        }
示例#3
0
        public ActionResult Post([FromBody] MClient mclient)
        {
            var mclients = MClientRepository.GetMClients().ToList();

            mclient.Id = GetNewId(mclients);
            mclients.Add(mclient);

            MClientRepository.StoreMClient(mclients);
            return(Ok());
        }
示例#4
0
        public ActionResult <MClient> Get(int id)
        {
            var mclients = MClientRepository.GetMClients();
            var mclient  = mclients.FirstOrDefault(x => x.Id == id);

            if (mclient != null)
            {
                return(Ok(mclient));
            }

            return(NotFound());
        }
示例#5
0
        public void Get_WithInvalidId_ClientIsNull()
        {
            // Arrange
            var id = 1;

            // Act
            var clients = MClientRepository.GetMClients();
            var client  = clients.FirstOrDefault(x => x.Id == id);

            // Assert
            Assert.Null(client);
        }
示例#6
0
        public ActionResult Delete(int id)
        {
            var mclients = MClientRepository.GetMClients().ToList();

            var mclientToDelete = mclients.FirstOrDefault(p => p.Id == id);

            if (mclientToDelete != null)
            {
                mclients.Remove(mclientToDelete);
                MClientRepository.StoreMClient(mclients);
                return(Ok());
            }

            return(NotFound());
        }
示例#7
0
        public ActionResult Put([FromBody] MClient mclient)
        {
            var mclients = MClientRepository.GetMClients().ToList();

            var mclientToUpdate = mclients.FirstOrDefault(p => p.Id == mclient.Id);

            if (mclientToUpdate != null)
            {
                mclientToUpdate.FirstName    = mclient.FirstName;
                mclientToUpdate.LastName     = mclient.LastName;
                mclientToUpdate.CarType      = mclient.CarType;
                mclientToUpdate.LicensePN    = mclient.LicensePN;
                mclientToUpdate.Description  = mclient.Description;
                mclientToUpdate.StartingDate = mclient.StartingDate;
                mclientToUpdate.Status       = mclient.Status;


                MClientRepository.StoreMClient(mclients);
                return(Ok());
            }

            return(NotFound());
        }