示例#1
0
        public ActionResult Post([FromBody] MClient mclient)
        {
            var mclients = MClientRepository.GetMClients().ToList();

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

            MClientRepository.StoreMClient(mclients);
            return(Ok());
        }
示例#2
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());
        }
示例#3
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());
        }