예제 #1
0
        public void ConnectMobile(Guid id)
        {
            var mobile = GetMobileById(id);

            if (!mobile.IsAvailable)
            {
                mobile.IsAvailable = true;
                _mobileRepository.Update(mobile);
                StoreMobiles();
            }
        }
예제 #2
0
        public ActionResult PutMobile([FromBody] MobileForm model)
        {
            var dbModel = mobileRepository.Get(model.Id);

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

            mapper.Map <MobileForm, Mobile>(model, dbModel);
            mobileRepository.Update(dbModel);

            return(Ok());
        }
예제 #3
0
        public async Task <Object> UpdateMobile(int id, UpdateMobileModelView MobileFromView)
        {
            try
            {
                Mobile mobileToUpdate = await _mobileRepo.GetById(id);

                if (mobileToUpdate == null)
                {
                    return(BadRequest($"le record avec l'id : {id} n'existe pas"));
                }

                Mobile UpdatedMobile = new Mobile()
                {
                    Id          = mobileToUpdate.Id,
                    Codeclient  = MobileFromView.Codeclient,
                    Numero      = mobileToUpdate.Numero,
                    Data        = MobileFromView.Data,
                    Forfait     = MobileFromView.Forfait,
                    Societe     = MobileFromView.Sociéte,
                    Nom         = MobileFromView.Nom,
                    Handset     = MobileFromView.Handset,
                    Montant     = MobileFromView.Montant,
                    Prixhandset = MobileFromView.Prixhandset,
                    Site        = MobileFromView.Site
                };

                Historique HistoriqueObject = await _mobileRepo.CompareMobilesRecords(mobileToUpdate, UpdatedMobile);

                UpdatedMobile.Historiques.Add(HistoriqueObject);
                await _mobileRepo.Update(UpdatedMobile);


                return(Ok(new { success = true, status = "le record est bien mis a jour", data = mobileToUpdate }));
            }
            catch (Exception e)
            {
                return(BadRequest(new { status = "un erreur est servenue", exception = e }));
            }
        }