Ejemplo n.º 1
0
        public void VendorRegPost(RegVendorViewModel rv, String id)
        {
            using (PetsPlanetDBContext db = new PetsPlanetDBContext())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        #region ***UserTable entry***

                        User_Info ui = new User_Info();
                        ui.US_Name        = rv.US_Name;
                        ui.US_Phone       = rv.US_Phone;
                        ui.US_Address     = rv.US_Address;
                        ui.US_Email       = rv.US_Email;
                        ui.U_Id           = 12;
                        ui.US_Password    = rv.US_Password;
                        ui.IsValid        = 0;
                        ui.US_ConfirmCode = id;

                        db.User_Info.Add(ui);
                        #endregion   ***UserTable enrty***


                        #region ***VendorImage entry***
                        Vendor_Image vi = new Vendor_Image();
                        vi.VendorImage_Name      = rv.VendorImage_Name;
                        vi.VendorImage_ImagePath = rv.VendorImage_ImagePath;

                        db.Vendor_Image.Add(vi);
                        #endregion ***VendorImage entry***


                        #region ***Vendor Details***

                        Vendor_Info Vinfo = new Vendor_Info();
                        Vinfo.VI_CNIC        = rv.VI_CNIC;
                        Vinfo.VI_Province    = rv.VI_Province;
                        Vinfo.VI_City        = rv.VI_City;
                        Vinfo.US_Id          = ui.US_Id;
                        Vinfo.VI_Approved    = 0;
                        Vinfo.VI_NotApproved = 0;
                        Vinfo.VendorImage_Id = vi.VendorImage_Id;

                        db.Vendor_Info.Add(Vinfo);
                        db.SaveChanges();
                        #endregion ***Vendor Details***

                        transaction.Commit();
                    }
                    catch
                    {
                        transaction.Rollback();
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public RegVendorViewModel GetVendorDetails(int id)
 {
     using (var db = new PetsPlanetDBContext())
     {
         var                details = db.VendorDetails(id);
         UserPresenter      pp      = new UserPresenter();
         RegVendorViewModel rvm     = new RegVendorViewModel();
         foreach (var item in details)
         {
             rvm.US_Name               = item.US_Name;
             rvm.US_Phone              = item.US_Phone;
             rvm.US_Address            = item.US_Address;
             rvm.US_Email              = item.US_Email;
             rvm.VI_CNIC               = item.VI_CNIC;
             rvm.VI_Province           = item.VI_Province;
             rvm.VI_City               = item.VI_City;
             rvm.VendorImage_Id        = item.VendorImage_Id;
             rvm.VendorImage_ImagePath = item.VendorImage_ImagePath;
         }
         return(rvm);
     }
 }