public ActionResult EditProfile()
        {
            var userSvc = new UserLogic(Ticket);
            ViewData.Model = userSvc.GetCurrent();

            return View();
        }
Exemple #2
0
        public void CorrectUserCreationTest()
        {
            var testUser = new UserLogic();
            testUser.Id = 1;
            testUser.Name = "testName";
            testUser.Metadata = "testData";

            Assert.AreEqual(1, testUser.Id);
            Assert.AreEqual("testName", testUser.Name);
            Assert.AreEqual("testData", testUser.Metadata);
        }
Exemple #3
0
 public void TeamInitialize()
 {
     testTeam = new TeamLogic();
     var user = new UserLogic();
     var user2 = new UserLogic();
     users.Add(user);
     users.Add(user2);
     testTeam.Id = 1;
     testTeam.Name = "testName";
     testTeam.Metadata = "testData";
     testTeam.Users = users;
 }
        public ActionResult EditProfile(FormCollection form)
        {
            var userSvc = new UserLogic(Ticket);
            var userObj = userSvc.GetCurrent();

            userObj.Name = form["name"];
            userObj.PhoneNumber = form["phoneNumber"];
            userObj.MobileNumber = form["mobileNumber"];
            userObj.EmailAddress = form["emailAddress"];

            userSvc.Save(userObj);

            Ticket.UserName = form["name"];
            DisplayInformation("Your profile has been updated successfully.");

            return RedirectToAction("Profile");
        }
        public ActionResult ChangePassword(FormCollection form)
        {
            var oldPassword = form["oldPassword"];
            var newPassword = form["newPassword"];

            var userSvc = new UserLogic(Ticket);
            if (userSvc.ChangePassword(oldPassword, newPassword))
            {
                DisplayInformation("Your password has been successfully changed.");
                return RedirectToAction("Profile");
            }
            else
            {
                DisplayError(userSvc.ErrorMessage);
                return View();
            }
        }
Exemple #6
0
 public void UserInit()
 {
     userLogic = new UserLogic(testCtx);
 }
Exemple #7
0
        public ActionResult Register(FormCollection form)
        {
            if (form == null)
            {
                return(View());
            }
            else if (form.AllKeys.Count() < 1)
            {
                return(View());
            }
            else
            {
                if (form.AllKeys.Contains("id_token")) //google sign in
                {
                    HttpClient client        = new HttpClient();
                    string     tokenResponse = client.GetAsync("https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=" + form["id_token"]).Result.Content.ReadAsStringAsync().Result;
                    dynamic    data          = JObject.Parse(tokenResponse);
                    if (data.email_verified == "true")
                    {
                        if (UserLogic.IsRegisteredGoogleUser("google-" + data.sub))
                        {
                            AppCookies.setCookie(AppCookies.UserId, "google-" + data.sub);
                            return(Json(new { action = "/" }));
                        }
                        else
                        {
                            //register new google user
                            GoogleUser user = new GoogleUser();
                            user.DateCreated   = user.DateUpdated = DateTime.Now;
                            user.EmailVerified = true;
                            user.EMail         = form["Email"];
                            user.UserName      = user.Name = form["Name"];
                            user.ImageUrl      = form["ImageURL"];
                            user.GoogleID      = "google-" + data.sub;
                            new GoogleUserDAO().Save(user);
                            AppCookies.setCookie(AppCookies.UserId, "google-" + data.sub);
                            return(Json(new { action = "/" }));
                        }
                    }
                    else
                    {
                        //
                        return(Json(new { action = "", error = "OneDice could not verify your google information" }));
                    }
                }
                else
                {
                    //register new user
                    OneDice.Core.User user = new User();
                    user.DateCreated = user.DateUpdated = DateTime.Now;
                    user.UserName    = user.Name = form["register-username"];
                    user.EMail       = form["register-email"];
                    user.Password    = AppSecurity.SHA1Encrypt(form["register-password"]);
                    var userDao = new UserDAO();
                    userDao.Save(user);

                    AppCookies.setCookie(AppCookies.UserId, userDao.Table.Where(x => x.EMail == user.EMail).FirstOrDefault().ID.ToString());
                    return(Json(new { action = "/" }));
                }
            }
        }
 public User Register(User newUser)
 {
     System.Diagnostics.Debug.WriteLine(newUser);
     return(UserLogic.Register(newUser));
 }
Exemple #9
0
        public int InsertNewUser(String UserName, String Password, int UserLevel, String Email)
        {
            UserLogic userLogic = new UserLogic();

            return(userLogic.AddNewUser(UserName, Password, UserLevel, Email));
        }
Exemple #10
0
 public UserController(IHubContext <Notification> hub)
 {
     _hub       = hub;
     _userLogic = new UserLogic();
 }
Exemple #11
0
        static void Main(string[] args)
        {
            LanguageLogic         languageLogic         = new LanguageLogic();
            UserLogic             userLogic             = new UserLogic();
            UserFleetLogic        userFleetLogic        = new UserFleetLogic();
            FleetLogic            fleetLogic            = new FleetLogic();
            VehicleLogic          vehicleLogic          = new VehicleLogic();
            DriverLogic           driverLogic           = new DriverLogic();
            ConfigTagLogic        configTagLogic        = new ConfigTagLogic();
            ConfigTagLanguageCrud configTagLanguageCrud = new ConfigTagLanguageCrud();
            FunctionsLogic        functionsLogic        = new FunctionsLogic();
            ConfigUserLoginLogic  configUserLoginLogic  = new ConfigUserLoginLogic();
            Mail             mail             = new Mail();
            UserRestoreLogic userRestoreLogic = new UserRestoreLogic();
            CarFleetSecurity secCarFleet      = CarFleetSecurity.GetContext;

            //List<LanguageEntity> listLanguage = languageLogic.SelectAll();
            //LanguageEntity languageEntity = languageLogic.GetById(1);
            //UserEntity userEntity = userLogic.Login("ManuelM");
            //List<UserFleetEntity> listuserFleet = userFleetLogic.SelectByUserId(userEntity.Id);
            //List<FleetEntity> listFleet = fleetLogic.GetByCompanyId(userEntity.Id_company);
            //List<VehicleEntity> listVehicle = vehicleLogic.GetByCompanyId(userEntity.Id_company);
            //List<VehicleEntity> listVehicle2 = vehicleLogic.GetByFleetId(listFleet.FirstOrDefault().Id);
            //List<DriverEntity> listDriver = driverLogic.GetByCompanyId(userEntity.Id_company);
            //ConfigTagEntity configTagEntity=new ConfigTagEntity();
            //configTagEntity.Tag_key = "lblUser";
            //configTagEntity.Page_name = "Login";
            //configTagLogic.Insert(configTagEntity);
            //int totalDriver = functionsLogic.GetTotalsByCompanyId(2099, Utils.Constants.CARFLEET_ENTITY.DRIVER);
            //int totalFleet= functionsLogic.GetTotalsByCompanyId(2099, Utils.Constants.CARFLEET_ENTITY.FLEET);
            //int totalVehicle = functionsLogic.GetTotalsByCompanyId(2099, Utils.Constants.CARFLEET_ENTITY.VEHICLE);
            //string token=configUserLoginLogic.Insert(4188, "", 1800);

            string pass        = CarFleetSecurityCipher.Encrypt("ManuelM");
            string passDecrypt = CarFleetSecurityCipher.Decrypt(pass);

            string        email       = "ManuelM";
            List <string> addressList = new List <string>();

            addressList.Add("*****@*****.**");

            string     errorMessage;
            UserEntity userEntity = userLogic.SelectByLoginName(email);

            if (userEntity != null)
            {
                Random random         = new Random();
                string code           = random.Next(10000, 99999).ToString();
                int    timeExpiration = secCarFleet.GetNumberConfig(CarFleetSecurity.APP_CONFIG_RESTORE_PASSWORD_TIME_EXPIRE);
                if (userRestoreLogic.Insert(userEntity.Id, code, timeExpiration))
                {
                    Mail carFleetMail = new Mail();
                    var  sendMail     = carFleetMail.RestorePassword("*****@*****.**", code, out errorMessage);
                }
                if (userRestoreLogic.IsValidCode(email, code, out errorMessage))
                {
                    string newPassword = "******";
                    var    updatePass  = userLogic.UpdatePassword(email, newPassword);
                }
            }


            var f = 234;
        }
 public ModifyPriceModel(CarServiceDbContext context, IEmailSender emailSender)
 {
     _workSheetLogic = new WorkSheetLogic(context);
     _userLogic = new UserLogic(context);
     _emailLogic = new EmailLogic(context, emailSender);
 }
Exemple #13
0
 public UserController()
 {
     _logic     = new UserLogic();
     _logicRole = new RoleLogic();
 }
        protected void searchsubmit_OnServerClick(object sender, EventArgs e)
        {
            //var userDB = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<IUserDb>();

            try
            {
                if (string.IsNullOrWhiteSpace(TextBoxNameFName.Value))
                {
                    throw new Exception("First Name field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNameLName.Value))
                {
                    throw new Exception("Last Name field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNameEmail.Value))
                {
                    throw new Exception("Email field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNameUName.Value))
                {
                    throw new Exception("User Name field is required");
                }
                if (string.IsNullOrWhiteSpace(TextBoxNamePhone.Value))
                {
                    throw new Exception("Phone No. field is required");
                }

                IList <Core.User> AdminList = Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IUserDb>().RetrievebyAdminRole();

                if (AdminList.Count == 0)
                {
                    //create headquarters branch for user
                    Branch branch = new Branch
                    {
                        Address     = "Coconut Bus Stop",
                        BranchName  = "HeadQuarters",
                        DateAdded   = DateTime.Now,
                        DateUpdated = DateTime.Now,
                        RcNumber    = "00000"
                    };
                    Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IBranchDb>().InsertData(branch);
                    //User user =Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance<IUserDb>();
                    User user = new User();
                    user.FirstName  = TextBoxNameFName.Value;
                    user.LastName   = TextBoxNameLName.Value;
                    user.OtherNames = TextBoxNameONames.Value;
                    user.FullName   = user.FirstName + "" + user.LastName + "" + user.OtherNames;
                    //user.Branch = BranchTextbox.Text;            should inherit from type Branch
                    user.Email = TextBoxNameEmail.Value;
                    //user.Role = RoleTextBox.Text;                should be an enum
                    user.UserName    = TextBoxNameUName.Value;
                    user.PhoneNumber = TextBoxNamePhone.Value;
                    user.UserRole    = (Role)Enum.Parse(typeof(Role), DropDownRole.SelectedValue);
                    user.Branch      = new Branch();
                    //string userBranchId = BranchDropDown.SelectedValue;
                    //string userbranchname = BranchDropDown.Text;
                    user.Branch.Id         = branch.Id;
                    user.Branch.BranchName = branch.BranchName;


                    UserLogic userLogic = new UserLogic();
                    user.Password = userLogic.EncryptPassword(userLogic.CreatePassword());


                    user.DateAdded   = DateTime.Now;
                    user.DateUpdated = DateTime.Now;
                    Microsoft.Practices.ServiceLocation.ServiceLocator.Current.GetInstance <IUserDb>().InsertData(user);
                    userLogic.SendMail(user.Email, user.Password);
                    //Response.Redirect("../Start/Login.aspx");
                }

                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Admin User Created Already. Only One Admin Can Be Created Through This Page" + "', function(){});</script>", false);
                }


                TextBoxNameFName.Value  = String.Empty;
                TextBoxNameLName.Value  = String.Empty;
                TextBoxNameONames.Value = String.Empty;
                //BranchTextbox.Text = String.Empty;
                TextBoxNameEmail.Value = String.Empty;
                //RoleTextBox.Text = String.Empty;
                TextBoxNameUName.Value = String.Empty;
                TextBoxNamePhone.Value = String.Empty;

                if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Admin Saved Successfully" + "', function(){location = '/Start/Login.aspx';});</script>", false);
                }
            }
            catch (Exception ex)
            {
                string errorMessage = ex.InnerException == null ? ex.Message : ex.InnerException.Message;
                if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", @"<script type='text/javascript'>alertify.alert('Message', """ + errorMessage.Replace("\n", "").Replace("\r", "") + @""", function(){});</script>", false);
                }
            }
        }
        public ActionResult Login(FormCollection values, string returnUrl)
        {
            var userCode = values["userName"];
            var password = values["password"];
            var rememberMe = values["rememberMe"] == "on" ? true : false;

            var userSvc = new UserLogic(Ticket);
            userSvc.Authenticate(userCode, password);

            if (!userSvc.Authenticate(userCode, password))
            {
                DisplayError(userSvc.ErrorMessage);
                ViewData.Add("returnUrl", returnUrl);
                ViewData.Add("userName", userCode);

                return View();
            }

            if (rememberMe)
            {
                var defaultCookie = new HttpCookie("defaultCredentials", userCode);
                defaultCookie.Expires = DateTime.Now.AddMonths(1);
                HttpContext.Response.Cookies.Add(defaultCookie);
            }

            if (string.IsNullOrEmpty(returnUrl))
            {
                return Redirect("~/");
            }
            else
            {
                return Redirect(returnUrl);
            }
        }
 public RegisterAsHostModel(UserManager <ApplicationUser> userManager,
                            SignInManager <ApplicationUser> signInManager,
                            RoleManager <IdentityRole> roleManager)
 {
     userLogic = new UserLogic(userManager, signInManager, roleManager);
 }
Exemple #17
0
 //Instantiating the logic classes
 public UserController()
 {
     userLogic    = new UserLogic();
     sectionLogic = new SectionLogic();
 }
Exemple #18
0
 public UserController()
 {
     logic = new UserLogic();
 }
Exemple #19
0
 public SessionController(IUserContext context)
 {
     _userLogic = new UserLogic(context);
 }
Exemple #20
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            User worker = new User();

            worker.UserName = txt_name.Text;
            string password = txt_password.Text;

            //validation password
            if (password.Length < 4 || password.Length > 4)
            {
                MessageBox.Show("password must contains 4 chars.");
                return;
            }
            //convert password to sha256
            worker.Password     = UserLogic.passwordToSHA(txt_password.Text);
            worker.NumHoursWork = num_numHours.Value;
            worker.Email        = txt_email.Text;
            worker.DepartmentId = (cmbx_department.SelectedItem as DepartmentUser).Id;

            if (cmbx_teamLeader.Items.Count != 0)
            {
                worker.ManagerId = (cmbx_teamLeader.SelectedItem as User).UserId;
            }
            else
            {
                worker.ManagerId = 0;
            }

            try
            {
                var httpWebRequest = (HttpWebRequest)WebRequest.Create(@"http://localhost:61309/api/addUser");
                httpWebRequest.ContentType = "application/json";
                httpWebRequest.Method      = "POST";
                using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    string NewUserString = Newtonsoft.Json.JsonConvert.SerializeObject(worker, Formatting.None);
                    streamWriter.Write(NewUserString);
                    streamWriter.Flush();
                    streamWriter.Close();
                }
                //Gettting response
                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

                //Reading response
                using (var streamReader = new System.IO.StreamReader(httpResponse.GetResponseStream(), ASCIIEncoding.ASCII))
                {
                    string result = UserLogic.addUser(worker);

                    //If Add succeeded
                    if (result == null)
                    {
                        MessageBox.Show("the worker added");
                    }
                    else
                    {
                        MessageBox.Show("ERROR!!!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("error add new worker");
            }
        }
Exemple #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                System.Security.Principal.IPrincipal user = System.Web.HttpContext.Current.User;

                UserLogic uLogic = new UserLogic();

                SystemUsers currentUser = uLogic.GetCurrentUser(user);

                if (!String.IsNullOrEmpty(currentUser.DisplayName))
                {
                    lblUser.Text = currentUser.DisplayName;
                }

                if (currentUser.Status == 1)
                {
                    if (currentUser.UserRole.RoleName == "ReportsUser" || currentUser.UserRole.RoleName == "ReportsAdmin" || currentUser.UserRole.RoleName == "SuperUser" ||
                        currentUser.UserRole.RoleName == "Developer")
                    {
                        miReports.Visible = true;
                        phSearch.Visible  = true;
                    }
                    else
                    {
                        phSearch.Visible  = false;
                        miReports.Visible = false;
                    }

                    if (currentUser.UserRole.RoleName == "SuperUser" || currentUser.UserRole.RoleName == "Developer")
                    {
                        miAdmin.Visible = true;
                    }
                    else
                    {
                        miAdmin.Visible = false;
                    }

                    if (currentUser.InventoryApprovalUser.HasValue && currentUser.InventoryApprovalUser.Value == true)
                    {
                        miInventoryApproval.Visible = true;
                    }
                    else
                    {
                        miInventoryApproval.Visible = false;
                    }
                }
                else
                {
                    miForms.Visible             = false;
                    miReports.Visible           = false;
                    miAdmin.Visible             = false;
                    phSearch.Visible            = false;
                    miInventoryApproval.Visible = false;
                    Response.Redirect("/Unauthorized");
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemple #22
0
 public UcEditUser(User user)
 {
     InitializeComponent();
     _user  = user;
     _logic = new UserLogic();
 }
Exemple #23
0
 public DeleteUserConsumer(IModel channel, UserLogic userLogic, LogLogic logLogic)
 {
     _channel   = channel;
     _userLogic = userLogic;
     _logLogic  = logLogic;
 }
Exemple #24
0
 public LoginUserHandler(UserLogic userLogic)
 {
     _userLogic = userLogic;
 }
Exemple #25
0
        public int DeleteUserByUserID(int UserID)
        {
            UserLogic userLogic = new UserLogic();

            return(userLogic.DeleteUserByUserID(UserID));
        }
Exemple #26
0
        /// <summary>
        /// 获取用户信息
        /// </summary>
        private void GetUserInfo()
        {
            var data = UserLogic.GetModel(UserId);

            json = JsonHelper.JsonSerializer(new ResultModel(ApiStatusCode.OK, data));
        }
 public User Login(User existingUser)
 {
     return(UserLogic.Login(existingUser.firstName, existingUser.id));
 }
Exemple #28
0
        /// <summary>
        /// 获取等级
        /// </summary>
        public void GetLevelList()
        {
            var data = UserLogic.GetLevelList(GetFormValue("type", -1));

            json = JsonHelper.JsonSerializer(new ResultModel(ApiStatusCode.OK, data));
        }
 public UserLogicTests()
 {
     _mockUserRepository = new Mock <IUserRepository>();
     _target             = new UserLogic(_mockUserRepository.Object);
 }
Exemple #30
0
 public ExerciseController()
 {
     logic = new UserLogic();
 }
Exemple #31
0
        public JsonResult SendVerifyMobileCode(UserRegisterViewModel a)
        {
            var code = UserLogic.SendValidCode(a.Phone);

            return(Json(code));
        }
        public void GetWinnerBoard_10Users_Returns5HighestScoores()
        {
            var userLogic = new UserLogic(userRepository.Object, passengerLogic.Object, mapper.Object);

            List <User> allUsers = new List <User> {
                new User {
                    Email = "1"
                },
                new User {
                    Email = "2"
                },
                new User {
                    Email = "3"
                },
                new User {
                    Email = "4"
                },
                new User {
                    Email = "5"
                },
                new User {
                    Email = "6"
                },
                new User {
                    Email = "7"
                },
                new User {
                    Email = "8"
                },
                new User {
                    Email = "9"
                },
                new User {
                    Email = "10"
                },
            };

            passengerLogic.Setup(x => x.GetUsersPoints("1")).Returns(6);
            passengerLogic.Setup(x => x.GetUsersPoints("2")).Returns(2);
            passengerLogic.Setup(x => x.GetUsersPoints("3")).Returns(5);
            passengerLogic.Setup(x => x.GetUsersPoints("4")).Returns(6);
            passengerLogic.Setup(x => x.GetUsersPoints("5")).Returns(67);
            passengerLogic.Setup(x => x.GetUsersPoints("6")).Returns(8);
            passengerLogic.Setup(x => x.GetUsersPoints("7")).Returns(0);
            passengerLogic.Setup(x => x.GetUsersPoints("8")).Returns(9);
            passengerLogic.Setup(x => x.GetUsersPoints("9")).Returns(11);
            passengerLogic.Setup(x => x.GetUsersPoints("10")).Returns(21);

            mapper.Setup(x => x.Map <User, UserDto>(allUsers[0])).Returns(new UserDto {
                Email = allUsers[0].Email
            });
            mapper.Setup(x => x.Map <User, UserDto>(allUsers[1])).Returns(new UserDto {
                Email = allUsers[1].Email
            });
            mapper.Setup(x => x.Map <User, UserDto>(allUsers[2])).Returns(new UserDto {
                Email = allUsers[2].Email
            });
            mapper.Setup(x => x.Map <User, UserDto>(allUsers[3])).Returns(new UserDto {
                Email = allUsers[3].Email
            });
            mapper.Setup(x => x.Map <User, UserDto>(allUsers[4])).Returns(new UserDto {
                Email = allUsers[4].Email
            });
            mapper.Setup(x => x.Map <User, UserDto>(allUsers[5])).Returns(new UserDto {
                Email = allUsers[5].Email
            });
            mapper.Setup(x => x.Map <User, UserDto>(allUsers[6])).Returns(new UserDto {
                Email = allUsers[6].Email
            });
            mapper.Setup(x => x.Map <User, UserDto>(allUsers[7])).Returns(new UserDto {
                Email = allUsers[7].Email
            });
            mapper.Setup(x => x.Map <User, UserDto>(allUsers[8])).Returns(new UserDto {
                Email = allUsers[8].Email
            });
            mapper.Setup(x => x.Map <User, UserDto>(allUsers[9])).Returns(new UserDto {
                Email = allUsers[9].Email
            });


            userRepository.Setup(x => x.GetAllUsers()).Returns(allUsers);

            var points       = userLogic.GetWinnerBoard();
            var expectedKeys = new List <string> {
                "10", "9",
            };

            var actualKeys = new List <UserDto>(points.Select(x => x.Item1));
            var keyStrings = new List <string>(actualKeys.Select(x => x.Email));

            Assert.AreEqual(points[0].Item2, 67);
            Assert.AreEqual(points[1].Item2, 21);
            Assert.AreEqual(points[2].Item2, 11);
            Assert.AreEqual(points[3].Item2, 9);
            Assert.AreEqual(points[4].Item2, 8);

            Assert.AreEqual(points.Count, 5);

            Assert.IsTrue(expectedKeys.TrueForAll(x => keyStrings.Contains(x)));
        }
Exemple #33
0
 public UserController(UserLogic userLogic, FoodlogLogic foodlogLogic, RightLogic rightLogic)
 {
     _userLogic    = userLogic;
     _foodlogLogic = foodlogLogic;
     _rightLogic   = rightLogic;
 }
Exemple #34
0
        private async void addAddressTap_Tapped(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(house_no.Text))
                {
                    Config.ErrorSnackbarMessage(ValidationMessages.HouseNoRequired);
                }
                else if (string.IsNullOrWhiteSpace(street_details.Text))
                {
                    Config.ErrorSnackbarMessage(ValidationMessages.StreetDetailRequired);
                }
                else if (country.SelectedIndex == 0)
                {
                    Config.ErrorSnackbarMessage(ValidationMessages.CountryRequired);
                }
                else if (state.SelectedIndex == 0)
                {
                    Config.ErrorSnackbarMessage(ValidationMessages.StateRequired);
                }
                else if (city.SelectedIndex == 0)
                {
                    Config.ErrorSnackbarMessage(ValidationMessages.CityRequired);
                }
                else if (string.IsNullOrWhiteSpace(pincode.Text))
                {
                    Config.ErrorSnackbarMessage(ValidationMessages.PincodeRequired);
                }
                else if (pincode.Text.Length < 5)
                {
                    Config.ErrorSnackbarMessage(ValidationMessages.PincodeMinimum);
                }
                else
                {
                    Config.ShowDialog();
                    UserAddress userAddress = new UserAddress
                    {
                        //address_type = address_type.Items[address_type.SelectedIndex],
                        //address_type = address_type.SelectedItem.ToString(),
                        //apartment_name = apartment_name.Items[apartment_name.SelectedIndex],
                        //area_details = area_details.Items[area_details.SelectedIndex],
                        country          = country.Items[country.SelectedIndex],
                        state            = state.Items[state.SelectedIndex],
                        city             = city.Items[city.SelectedIndex],
                        house_no         = house_no.Text,
                        landmark_details = landmark_details.Text,
                        street_details   = street_details.Text,
                        pincode          = pincode.Text,
                        user_id          = int.Parse(Application.Current.Properties["user_id"].ToString()),
                        name             = Application.Current.Properties["name"].ToString(),
                        mobile_number    = Application.Current.Properties["mobile_number"].ToString(),
                        //default_address = default_address.IsChecked ? 1 : 0,
                        default_address = 1,
                    };

                    var response = new GeneralResponse();
                    if (UserAddress != null)
                    {
                        userAddress.id = UserAddress.id;
                        response       = await UserLogic.SaveAddress(userAddress);

                        Config.HideDialog();
                    }
                    else
                    {
                        response = await UserLogic.AddAddress(userAddress);

                        Config.HideDialog();
                    }
                    if (response.status == 200)
                    {
                        Config.HideDialog();
                        //if (default_address.IsChecked)
                        //{
                        //    Application.Current.Properties["full_address"] = response.full_address;
                        //}
                        await Navigation.PopAsync();
                    }
                    else
                    {
                        Config.HideDialog();
                        Config.ErrorSnackbarMessage(response.message);
                    }
                    Config.HideDialog();
                }
            }
            catch (Exception ex)
            {
                Config.HideDialog();
                Config.ErrorStore("AddAddressPage-addAddressTap_Tapped", ex.Message);
                Config.ErrorSnackbarMessage(Config.ApiErrorMessage);
            }
        }
Exemple #35
0
        private void buttonListUsers_Click(object sender, EventArgs e)
        {
            UserLogic userLogic = new UserLogic();

            dataGridViewListUsers.DataSource = userLogic.GetAllUser();
        }
Exemple #36
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            MessagingCenter.Send((App)Application.Current, "NavigationBar", _pageTitle);
            try
            {
                Config.ShowDialog();
                AddressType = new List <string>()
                {
                    "Home", "Office", "Other"
                };
                //address_type.ItemsSource = AddressType;


                Dictionary <string, string> data = new Dictionary <string, string>
                {
                    { "temp", "1" }
                };
                var countries = await UserLogic.GetCountry(data);

                countries.data.Insert(0, new Country()
                {
                    id = 0, name = "Select Country"
                });

                state.ItemsSource = new List <State>()
                {
                    new State()
                    {
                        id = 0, name = "Select State"
                    }
                };
                city.ItemsSource = new List <City>()
                {
                    new City()
                    {
                        id = 0, name = "Select City"
                    }
                };

                //var states = await UserLogic.GetState(data);
                //var cities = await UserLogic.GetCity(data);
                //var cities = await UserLogic.GetCityList();
                //var areas = await UserLogic.GetAreaList(3378);
                //city.ItemsSource = cities.data.ToList();
                country.ItemsSource = countries.data.ToList();
                //states.data.Insert(0, new State() { id = 0, name = "Select State" });
                //area_details.ItemsSource = areas.data.ToList();
                //var apartment = await UserLogic.GetApartmentList(areas.data.FirstOrDefault().id);
                //apartment.data.Insert(0, new Apartment() { id = 0, name = "Select Apartment" });
                //apartment_name.ItemsSource = apartment.data.ToList();

                //areas.data.Insert(0, new Area() { id = 0, name = "Select Area" });
                //area_details.ItemsSource = areas.data.ToList();

                if (UserAddress != null)
                {
                    var CountryId = countries.data.Where(a => a.name == UserAddress.country).First();
                    Dictionary <string, string> stateData = new Dictionary <string, string>
                    {
                        { "country_id", CountryId.id.ToString() }
                    };
                    var states = await UserLogic.GetState(stateData);

                    state.ItemsSource = states.data.ToList();
                    var StateId = states.data.Where(a => a.name == UserAddress.state).First();

                    Dictionary <string, string> cityData = new Dictionary <string, string>
                    {
                        { "state_id", StateId.id.ToString() }
                    };
                    var cities = await UserLogic.GetCity(cityData);

                    city.ItemsSource = cities.data.ToList();

                    //var areaData = areas.data.Where(a => a.name == UserAddress.area_details).FirstOrDefault();
                    var CountryIndex = countries.data.ToList().FindIndex(a => a.name == UserAddress.country);
                    var StateIndex   = states.data.ToList().FindIndex(a => a.name == UserAddress.state);
                    var CityIndex    = cities.data.ToList().FindIndex(a => a.name == UserAddress.city);
                    //var apartmentIndex = apartment.data.ToList().FindIndex(a => a.name == UserAddress.apartment_name);
                    var addressTypeIndex = AddressType.FindIndex(a => a == UserAddress.address_type);
                    //var cityIndex = cities.data.ToList().FindIndex(a => a.name == UserAddress.city);
                    house_no.Text         = UserAddress.house_no;
                    street_details.Text   = UserAddress.street_details;
                    landmark_details.Text = UserAddress.landmark_details;
                    pincode.Text          = UserAddress.pincode;
                    //default_address.IsChecked = (UserAddress.default_address == 0) ? false : true;

                    country.SelectedIndex = CountryIndex;
                    state.SelectedIndex   = StateIndex;
                    city.SelectedIndex    = CityIndex;
                    //area_details.SelectedIndex = areaIndex;
                    //apartment_name.SelectedIndex = apartmentIndex;
                    //address_type.SelectedIndex = addressTypeIndex;
                    addressLbl.Text = "Save Address";
                }
                else
                {
                    country.SelectedIndex = 0;
                    state.SelectedIndex   = 0;
                    //areas.data.Insert(0, new Area() { id = 0, name = "Select Area" });
                    city.SelectedIndex = 0;
                    //area_details.SelectedIndex = 0;
                    //apartment_name.SelectedIndex = 0;
                }
                Config.HideDialog();
            }
            catch (Exception ex)
            {
                Config.HideDialog();
                Config.ErrorStore("AddAddressPage-OnAppearing", ex.Message);
                Config.ErrorSnackbarMessage(Config.ApiErrorMessage);
            }
        }