Exemple #1
0
        public ActionResult Edit(int id)
        {
            var Governorate = uow.GovernorateRepo.GetAllGovernorates();

            //govs.Insert(0,new Governorate(){Code="",Name="اختر",ID = 0});
            ViewBag.govs = new SelectList(Governorate, "ID", "Name");

            Trader t = uow.TraderRepo.FindTraderById(id);

            if (t.Governorate != null)
            {
                List <City> city = uow.CityRepo.GetGovCities((int)t.Governorate);
                //city.Insert(0, new City { Code = "", Name = "اختر", ID = 0 });
                ViewBag.City = new SelectList(city, "ID", "Name", t.City);
                if (t.City != null)
                {
                    List <Region> district = uow.RegionRepo.GetCityRegions((int)t.City);
                    //district.Insert(0, new Region { Code = "", Name = "اختر", ID = 0 });
                    ViewBag.District = new SelectList(district, "ID", "Name", t.District);
                }
            }

            TraderViewModel traderVM = Mapper.Map <Trader, TraderViewModel>(t);

            traderVM.ReEmail = traderVM.Email;

            // t.ReEmail = t.Email;
            return(View("Edit", traderVM));
        }
Exemple #2
0
 public ActionResult Register(TraderViewModel m)
 {
     if (ModelState.IsValid)
     {
         using (SMSContext db = new SMSContext())
         {
             Random random    = new Random();
             var    salt      = Encryption.SHA1(Convert.ToString(random.Next(9999, 99999)));
             var    newTrader = new Trader
             {
                 DateCreated = m.DateCreated,
                 Name        = m.Name,
                 Address     = m.Address,
                 PhoneNumber = m.PhoneNumber,
                 Email       = m.Email,
                 Password    = Encryption.SHA1(m.Password + salt), //using salt
                 Salt        = salt
             };
             db.Trader.Add(newTrader);
             db.SaveChanges();
         }
         ModelState.Clear();
         ViewBag.Message = "Thank You !" + m.Name + " has been successfully registered.";
     }
     return(View());
 }
 public MainPage()
 {
     this.InitializeComponent();
     Trader = new TraderViewModel();
 }
Exemple #4
0
 public MainPage()
 {
     this.InitializeComponent();
     Trader = new TraderViewModel();
 }