Beispiel #1
0
 public void AddProvider(ProviderDto NewProvider)
 {
     if (IsExist(NewProvider) == false)
     {
         db.Providers.Add(ProviderToDal(NewProvider));
         db.SaveChanges();
     }
 }
Beispiel #2
0
        private bool IsExist(ProviderDto provider)
        {
            Boolean exist = false;

            db.Providers.ToList().ForEach(x =>
            {
                if (x.CompanyCode == provider.CompanyCode && x.CompanyName == provider.CompanyName)
                {
                    exist = true;
                }
            });
            return(exist);
        }
Beispiel #3
0
        public void UpdateProvider(ProviderDto UpProvider)
        {
            Provider Ezer = db.Providers.FirstOrDefault(m => m.Id == UpProvider.Id);

            if (Ezer != null)
            {
                Ezer.CompanyCode = UpProvider.CompanyCode;
                Ezer.CompanyName = UpProvider.CompanyName;
                Ezer.Address     = UpProvider.Address;
                Ezer.PhoneNumber = UpProvider.PhoneNumber;
                Ezer.CellNumber  = UpProvider.CellNumber;
                Ezer.Email       = UpProvider.Email;
                Ezer.UserName    = UpProvider.UserName;
                Ezer.Password    = UpProvider.Password;
                db.SaveChanges();
            }
        }
Beispiel #4
0
 private Provider ProviderToDal(ProviderDto Mdto)
 {
     if (Mdto != null)
     {
         return new Provider()
                {
                    //Id = Mdto.Id,
                    CompanyCode = Mdto.CompanyCode,
                    CompanyName = Mdto.CompanyName,
                    Address     = Mdto.Address,
                    PhoneNumber = Mdto.PhoneNumber,
                    CellNumber  = Mdto.CellNumber,
                    Email       = Mdto.Email,
                    UserName    = Mdto.UserName,
                    Password    = Mdto.Password
                }
     }
     ;
     else
     {
         return(null);
     }
 }