public async Task <Entities.Application.User> CreateOrUpdateUser(Entities.Application.User user) { var converted = _userMapper.ToDbEntity(user); var dbResult = await _userDao.CreateOrUpdateUser(converted); return(_userMapper.ToApplicationEntity(dbResult)); }
public void NameAdmin_InvalidUser_NotOk() { //Act var id = "1"; User currDbUser = new User { Admin = false }; User dbUser = new User { Admin = true }; GrooverAdm.Entities.Application.User result = new Entities.Application.User { Admin = true }; _userDao.Setup(a => a.GetUser(id)).Returns(Task.FromResult(currDbUser)); _userDao.Setup(a => a.SetAdmin(id)).Returns(Task.FromResult(currDbUser)); _userMapper.Setup(a => a.ToApplicationEntity(dbUser)).Returns(result); //Arrange IUserService userService = new UserService(_userDao.Object, _userMapper.Object, null); //This makes so that we can't test fireAuth methods, sucks //Assert Assert.ThrowsAsync <GrooverAuthException>(async() => await userService.NameAdmin(id, id)); }
public async Task NameAdmin_ValidUser_Ok() { //Act var id = "1"; User currDbUser = new User { Admin = true }; User dbUser = new User { Admin = true }; GrooverAdm.Entities.Application.User result = new Entities.Application.User { Admin = true }; _userDao.Setup(a => a.GetUser(id)).Returns(Task.FromResult(currDbUser)); _userDao.Setup(a => a.SetAdmin(id)).Returns(Task.FromResult(currDbUser)); _userMapper.Setup(a => a.ToApplicationEntity(dbUser)).Returns(result); //Arrange IUserService userService = new UserService(_userDao.Object, _userMapper.Object, null); //This makes so that we can't test fireAuth methods, sucks var res = await userService.NameAdmin(id, id); //Assert Assert.IsTrue(res.Admin); }
protected void btnLogin_Click(object sender, EventArgs e) { Entities.Application.User usr = new Entities.Application.User(); usr.UserName = txtUserName.Text; usr.Password = txtPassword.Text; Entities.OutputMessage result = null; result = usr.Authenticate(); if (result.Success) { Context.Session["UserDetails"] = result.Object; dynamic UserDetails = (dynamic)result.Object; HttpCookie bsl1 = new HttpCookie("bsl_1"); bsl1.Value = UserDetails.CompanyId; bsl1.Expires = DateTime.Now.AddDays(7); HttpCookie bsl2 = new HttpCookie("bsl_2"); bsl2.Value = UserDetails.LocationId; bsl2.Expires = DateTime.Now.AddDays(7); HttpCookie bsl3 = new HttpCookie("bsl_3"); bsl3.Value = UserDetails.UserId; bsl3.Expires = DateTime.Now.AddDays(7); HttpCookie bsl4 = new HttpCookie("bsl_4"); bsl4.Value = UserDetails.FinYear; bsl4.Expires = DateTime.Now.AddDays(7); Context.Response.Cookies.Add(bsl1); Context.Response.Cookies.Add(bsl2); Context.Response.Cookies.Add(bsl3); Context.Response.Cookies.Add(bsl4); FormsAuthentication.RedirectFromLoginPage(usr.UserName, chkRememberMe.Checked); } else { error.Visible = true; } }
public DataAccess.Firestore.Model.User ToDbEntity(Entities.Application.User entity) { var reference = _db.Collection(COLLECTION_REF).Document(entity.Id); return(new User { Born = entity.Born, CurrentToken = entity.CurrentToken, DisplayName = entity.DisplayName, ExpiresIn = entity.ExpiresIn, TokenEmissionTime = entity.TokenEmissionTime, Reference = reference, Admin = entity.Admin, Email = entity.Email, RefreshToken = entity.RefreshToken }); }
public async Task <string> GenerateToken(UserInfo userData, IAuthResponse credentials) { var auth = FirebaseAuth.GetAuth(this.firebase); try { await auth.GetUserAsync(userData.Id); // If the user does not exist an exception is thrown await auth.UpdateUserAsync(new UserRecordArgs() { Email = userData.Email, DisplayName = userData.Display_name, Uid = userData.Id, PhotoUrl = userData.Images.FirstOrDefault()?.Url }); } catch (FirebaseAuthException) { await auth.CreateUserAsync(new UserRecordArgs() { Email = userData.Email, DisplayName = userData.Display_name, Uid = userData.Id, PhotoUrl = userData.Images.FirstOrDefault()?.Url }); } var user = new Entities.Application.User(userData, credentials.Access_token, credentials.Expires_in, DateTime.UtcNow); if (!string.IsNullOrEmpty(credentials.Refresh_Token)) { user.RefreshToken = credentials.Refresh_Token; } await this.CreateOrUpdateUser(user); var token = await auth.CreateCustomTokenAsync(user.Id); return(token); }
protected void btnSaveConfirmed_Click(object sender, EventArgs e) { try { Entities.Application.User user = new Entities.Application.User(); user.ID = Convert.ToInt32(hdUserId.Value); user.UserName = txtUName.Text.Trim(); user.Password = txtPassword.Text.Trim(); user.FullName = txtFullName.Text.Trim(); user.EmployeeId = ddlEmpName.SelectedValue; user.ExpiryPeriod = Convert.ToInt32(ddlDays.SelectedValue); user.ForcePasswordChange = chkExpiry.Checked; user.CreatedBy = CPublic.GetuserID(); user.Disable = chkDisable.Checked; user.LocationId = Convert.ToInt32(ddlLoc.SelectedValue); user.ModifiedBy = CPublic.GetuserID(); user.CompanyId = CPublic.GetCompanyID(); OutputMessage result = null; if (user.ID == 0) { result = user.Save(); if (txtConfirmPass.Text != txtPassword.Text) { result = user.Authenticate(); if (result.Success) { ClientScript.RegisterStartupScript(GetType(), "message", "$('#add-item-portlet').addClass('in');errorAlert('" + result.Message + "');$('#add-item-portlet').addClass('in');", true); } else { result = user.Authenticate(); ClientScript.RegisterStartupScript(GetType(), "message", "successAlert('" + result.Message + "');", true); } } if (result.Success) { Reset(); ClientScript.RegisterStartupScript(GetType(), "message", "successAlert('" + result.Message + "');", true); } else { ClientScript.RegisterStartupScript(this.GetType(), "message", "$('#add-item-portlet').addClass('in');errorAlert('" + result.Message + "');$('#add-item-portlet').addClass('in');", true); } } else { result = user.Update(); if (result.Success) { Reset(); ClientScript.RegisterStartupScript(this.GetType(), "message", "successAlert('" + result.Message + "');", true); } else { ClientScript.RegisterStartupScript(this.GetType(), "message", "$('#add-item-portlet').addClass('in');errorAlert('" + result.Message + "');$('#add-item-portlet').addClass('in');", true); } } } catch (FormatException ex) { ClientScript.RegisterStartupScript(this.GetType(), "message", "$('#add-item-portlet').addClass('in');errorAlert('Enter a Valid Order');$('#add-item-portlet').addClass('in');", true); } }
protected void Page_Load(object sender, EventArgs e) { try { int id = Convert.ToInt32(Request.QueryString["id"]); int locationId = Convert.ToInt32(Request.QueryString["location"]); if (Request.QueryString["id"] != null && Request.QueryString["location"] != null) { Entities.Register.SalesReturnRegister sq = new Entities.Register.SalesReturnRegister(); sq = Entities.Register.SalesReturnRegister.GetDetails(id, locationId); dynamic setting = Entities.Application.Settings.GetFeaturedSettings(); Entities.Master.Company c = new Entities.Master.Company(); c = Entities.Master.Company.GetDetailsByLocation(locationId); Entities.Application.User use = new Entities.Application.User(); dynamic obj = Entities.Application.User.GetUserDetails(CPublic.GetuserID()); lblUserName.Text = obj.UserName; lblDesignation.Text = obj.Designation; lblCompanyContact.Text = obj.Mobile; lblCompanyEmail.Text = obj.Email; imgLogo.ImageUrl = "data:image/jpeg;base64, " + c.LogoBase64; imgLogo1.ImageUrl = "data:image/jpeg;base64, " + c.LogoBase64; imgLogo2.ImageUrl = "data:image/jpeg;base64, " + c.LogoBase64; imgLogo3.ImageUrl = "data:image/jpeg;base64, " + c.LogoBase64; //lblCustName.Text = sq.CustomerName; lblCompany.Text = sq.Company; lblCustemail.Text = sq.CustomerEmail; lblCustState.Text = sq.CustomerState + "," + sq.CustomerCountry; //lblCompanyContact.Text = c.MobileNo1; //lblCompanyEmail.Text = sq.CompanyEmail; lblDate.Text = sq.EntryDateString; //lblReference.Text = sq.CreditNoteNumber; //tAndC.Text = sq.TermsandConditon; //lblCustCompany.Text = sq.CustomerName; for (int i = 0; i < sq.Products.Count; i++) { TableRow r = new TableRow(); //TableCell t1 = new TableCell(); //t1.Text = (i + 1).ToString(); //r.Cells.Add(t1); TableCell t2 = new TableCell(); t2.Text = sq.Products[i].ItemCode; r.Cells.Add(t2); //TableCell t3 = new TableCell(); //t3.Text = sq.Products[i].Name; //r.Cells.Add(t3); if (setting.EnableDescription)//Enabled Description { TableCell t3 = new TableCell(); t3.Width = 500; string itemName = "<b>"; itemName += sq.Products[i].Name; itemName += "</b><br/>"; itemName += sq.Products[i].Description; t3.Text = itemName; r.Cells.Add(t3); } else { TableCell t3 = new TableCell(); t3.Text = sq.Products[i].Name; r.Cells.Add(t3); } TableCell t4 = new TableCell(); t4.Text = sq.Products[i].Quantity.ToString(); r.Cells.Add(t4); //TableCell t5 = new TableCell(); //t5.Text = sq.Products[i].MRP.ToString(); //r.Cells.Add(t5); TableCell t6 = new TableCell(); t6.Text = sq.Products[i].SellingPrice.ToString(); r.Cells.Add(t6); //TableCell t7 = new TableCell(); //t7.Text = sq.Products[i].TaxPercentage.ToString(); //r.Cells.Add(t7); //TableCell t8 = new TableCell(); //t8.Text = sq.Products[i].Gross.ToString(); //r.Cells.Add(t8); //TableCell t9 = new TableCell(); //t9.Text = sq.Products[i].TaxAmount.ToString(); //r.Cells.Add(t9); TableCell t10 = new TableCell(); t10.Text = sq.Products[i].NetAmount.ToString(); r.Cells.Add(t10); listTable.Rows.Add(r); } TableFooterRow tf = new TableFooterRow(); //TableCell tfc1 = new TableCell(); //tf.Cells.Add(tfc1); //TableCell tfc2 = new TableCell(); //tf.Cells.Add(tfc2); //TableCell tfc3 = new TableCell(); //tf.Cells.Add(tfc3); //TableCell tfc4 = new TableCell(); //tf.Cells.Add(tfc4); TableCell tfc5 = new TableCell(); tfc5.Text = "Total in " + setting.CurrencySymbol; tfc5.ColumnSpan = 4; tfc5.HorizontalAlign = HorizontalAlign.Right; tf.Cells.Add(tfc5); TableCell tfc6 = new TableCell(); tfc6.Text = Convert.ToString(sq.Gross); tfc6.HorizontalAlign = HorizontalAlign.Right; tf.Cells.Add(tfc6); listTable.Rows.Add(tf); TableFooterRow TaxAmountcell = new TableFooterRow(); TableCell tfc1 = new TableCell(); tfc1.Text = "VAT AMOUNT"; tfc1.ColumnSpan = 4; tfc1.HorizontalAlign = HorizontalAlign.Right; TaxAmountcell.Cells.Add(tfc1); TableCell tfc2 = new TableCell(); tfc2.Text = Convert.ToString(sq.TaxAmount); tfc2.HorizontalAlign = HorizontalAlign.Right; TaxAmountcell.Cells.Add(tfc2); listTable.Rows.Add(TaxAmountcell); TableFooterRow TotalCell = new TableFooterRow(); TableCell tfc3 = new TableCell(); tfc3.Text = "Grand Total in " + setting.CurrencySymbol; tfc3.ColumnSpan = 4; tfc3.HorizontalAlign = HorizontalAlign.Right; TotalCell.Cells.Add(tfc3); TableCell tfc4 = new TableCell(); tfc4.Text = Convert.ToString(sq.NetAmount); tfc4.HorizontalAlign = HorizontalAlign.Right; TotalCell.Cells.Add(tfc4); listTable.Rows.Add(TotalCell); } } catch (Exception ex) { Entities.Application.Helper.LogException(ex, "Quote | Page_Load(object sender, EventArgs e)"); Response.Write("<script> alert('" + ex.Message + "') </script>"); } }