Пример #1
0
        //-- END ADDING CHANGE OPERATION

        //-- GET LIST CHANGES BY EMPLOYE
        public List <ChangeDTO> GetListChangesByEmploye(int idEmploye)
        {
            List <ChangeDTO> changesDTO = new List <ChangeDTO>();

            foreach (Change change in _context
                     .Changes
                     .Where(e => e.employe.CodePersonne == idEmploye)
                     .ToList())
            {
                //-- TRANSFERING DATA TO DTO
                ChangeDTO changeDTO = new ChangeDTO();
                changeDTO.AdresseP         = change.AdresseP;
                changeDTO.ChangeType       = change.ChangeType;
                changeDTO.DateChange       = change.DateChange;
                changeDTO.Destination      = change.Destination;
                changeDTO.ExchangeRate     = change.ExchangeRate;
                changeDTO.FromCurrencyCode = change.FromCurrencyCode;
                changeDTO.FromCurrencyName = change.FromCurrencyName;
                changeDTO.Identif          = change.Identif;
                changeDTO.Montant          = change.Montant;
                changeDTO.MontantConverted = change.MontantConverted;
                changeDTO.NomP             = change.NomP;
                changeDTO.PrenomP          = change.PrenomP;
                changeDTO.ToCurrencyCode   = change.ToCurrencyCode;
                changeDTO.ToCurrencyName   = change.ToCurrencyName;
                //-- END TRANSFERING DATA TO DTO
                changesDTO.Add(changeDTO);
            }

            return(changesDTO);
        }
Пример #2
0
        public ChangeModel ChangeDTOToChangeModel(ChangeDTO changeDTO)
        {
            ChangeModel changeModel = new ChangeModel
            {
                Email          = changeDTO.Email,
                Img            = changeDTO.Img,
                Login          = changeDTO.Login,
                NewPassword    = changeDTO.NewPassword,
                OldPassword    = changeDTO.OldPassword,
                RepeatPassword = changeDTO.RepeatPassword,
                Token          = changeDTO.Token
            };

            return(changeModel);
        }
Пример #3
0
        public ChangeDTO ChangeModelToChangeDTO(ChangeModel changeModel)
        {
            ChangeDTO changeDTO = new ChangeDTO
            {
                Token          = MyUser.User.UserToken,
                Email          = changeModel.Email,
                Img            = changeModel.Img,
                Login          = changeModel.Login,
                NewPassword    = changeModel.NewPassword,
                OldPassword    = changeModel.OldPassword,
                RepeatPassword = changeModel.RepeatPassword
            };

            return(changeDTO);
        }
Пример #4
0
        public ChangeDTO ToDTO(ChangeEntity entity)
        {
            ChangeDTO dto = new ChangeDTO();

            dto.ID               = entity.ID;
            dto.UserID           = entity.UserID;
            dto.ToUserID         = entity.ID;
            dto.Amount           = entity.Amount;
            dto.ChangeType       = entity.ChangeType;
            dto.ChangeDate       = entity.ChangeDate;
            dto.CreateTime       = entity.CreateTime;
            dto.UserCode         = entity.UserInfo.UserCode;
            dto.TrueName         = entity.UserInfo.TrueName;
            dto.ToUserCode       = entity.ToUserInfo.UserCode;
            dto.ToTrueName       = entity.ToUserInfo.TrueName;
            dto.ChangeTypeName   = entity.ChangeTypeInfo.TypeName;
            dto.ChangeTypeNameEn = entity.ChangeTypeInfo.TypeNameEn;
            return(dto);
        }
Пример #5
0
        public bool ChangeAccount(ChangeDTO changeDTO)
        {
            IMainMap    map   = new Map();
            ChangeModel model = map.ChangeDTOToChangeModel(changeDTO);

            if (model.Img == null)
            {
                return(false);
            }
            if (model.Email == null)
            {
                return(false);
            }
            if (model.NewPassword == null)
            {
                return(false);
            }
            if (model.OldPassword == null)
            {
                return(false);
            }
            if (model.RepeatPassword == null)
            {
                return(false);
            }
            if (model.NewPassword != model.RepeatPassword)
            {
                return(false);
            }
            if (model.OldPassword != UsersData.UserList.Accounts[model.Token].Password)
            {
                return(false);
            }
            using (UserRepository repository = new UserRepository())
            {
                IMapUser mapSign = new Map();
                repository.Update(map.ChangeModelToUser(model));
                repository.Save();
                UsersData.UserList.Accounts[model.Token] = mapSign.UserToAccountModel(map.ChangeModelToUser(model));
                return(true);
            }
        }
Пример #6
0
        public bool ChangeAccount(ChangeDTO changeDTO)
        {
            IAccountLogic accountLogic = new AccountLogic();

            return(accountLogic.ChangeAccount(changeDTO));
        }
Пример #7
0
 public bool ChangeAccount(ChangeDTO changeDTO)
 {
     return(client.ChangeAccount(changeDTO));
 }
Пример #8
0
        //--END CONSTRUCTOR

        //-- METHODES

        //-- ADDING CHANGE OPERATION
        public Change AchatVenteDevise(ChangeDTO c)
        {
            Change change = new Change();

            //-- EXCEPTION
            if (c.CodeEmploye == 0 || c.ExchangeRate == 0 || c.FromCurrencyCode == null || c.FromCurrencyName == null || c.Identif == null || c.MontantConverted == 0 || c.NomP == null || c.PrenomP == null || c.ToCurrencyCode == null || c.ToCurrencyName == null)
            {
                throw new NullReferenceException("Error While Loading data ! try again ");
            }

            if (c.Montant <= 0)
            {
                throw new NullReferenceException("Invalid Amount ");
            }
            if (c.Identif.ToString().Length != 7)
            {
                throw new NullReferenceException("Identity Number Must be composed from 7 numbers !");
            }
            //-- END  EXCEPTION

            if (c.ChangeType == ChangeType.ACHAT)
            {
                //-- EXCEPTION
                if (c.AdresseP == null || c.Destination == null)
                {
                    throw new NullReferenceException("Error While Loading data ! try again ");
                }
                //-- END EXCEPTION
                c.ChangeType       = ChangeType.ACHAT;
                change.ChangeType  = c.ChangeType;
                change.AdresseP    = c.AdresseP;
                change.Destination = c.Destination;
            }
            else
            {
                c.ChangeType      = ChangeType.VENTE;
                change.ChangeType = c.ChangeType;
            }

            change.DateChange = DateTime.Now;
            Employe emp = _context.Employes.Find(c.CodeEmploye);

            change.employe          = emp;
            change.ExchangeRate     = c.ExchangeRate;
            change.FromCurrencyCode = c.FromCurrencyCode;
            change.FromCurrencyName = c.FromCurrencyName;
            change.Identif          = c.Identif;
            change.Montant          = c.Montant;
            change.MontantConverted = c.MontantConverted;
            change.NomP             = c.NomP;
            change.PrenomP          = c.PrenomP;
            change.ToCurrencyCode   = c.ToCurrencyCode;
            change.ToCurrencyName   = c.ToCurrencyName;

            //-- SAVING AND COMMITING
            _context.Changes.Add(change);
            Save();
            //-- END SAVING AND COMMITING

            return(change);
        }