public async Task CreateUser(RegisterUserInput user) { var role =_roleManager.FindByName(user.Role); var _user = new User { TenantId = 1, UserName = user.UserName, Name = user.FirstName, Surname = user.LastName, EmailAddress = user.Email, IsEmailConfirmed = true, Password = new PasswordHasher().HashPassword("ZXasqw12"), CreatorUser = _userRepository.Get(AbpSession.GetUserId()), CreatorUserId = AbpSession.GetUserId() }; _user.Roles = new List<UserRole> {new UserRole() {RoleId = role.Id}}; _userManager.Create(_user); GmailExtension gmail = new GmailExtension("*****@*****.**", "GOSALES2015"); gmail.SendMessage( "Welcome Aboard !", string.Format("<p> Welcome,</p><br/><br/><br/> <p> Your Animart registration has now been approved and your account is ready to use.<br/><br/>You may now log on to the system on http://shop.animart.co.id </p>" + "<br/><br/><p> Your user - id is: {0} and your password: ZXasqw12 </p><br/><br/><p> If you have any queries, please contact the Animart on + 62(22) 612 - 6824 </p>" + "<br/><br/><br/><p> Sincerely, </p><br/><br/><br/><p> PT.Animart Hobi Kreatif <br/>Tel: (+62) 22 - 612 - 6824 </p>", _user.UserName), _user.EmailAddress); }
public virtual async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model) { try { CheckModelState(); bool isActive = true; if (model.EmailAddress.IsNullOrEmpty()) { throw new UserFriendlyException("Please insert your email."); //L("FormIsNotValidMessage")); } //var provider = new DpapiDataProtectionProvider("AnimartRetailer"); //_userManager.UserTokenProvider = new DataProtectorTokenProvider<Users.User, long>(provider.Create("UserToken")); var _user = _userManager.FindByEmail(model.EmailAddress); if (_user != null) { var ResetCode = Guid.NewGuid().ToString(); ResetCode = new PasswordHasher().HashPassword(ResetCode); //await _userManager.GeneratePasswordResetTokenAsync(_user.Id); var TrimmedCode = ResetCode.Substring(0, Math.Min(Users.User.MaxPasswordResetCodeLength, ResetCode.Length)); _user.PasswordResetCode = TrimmedCode; //Switch to the tenant _unitOfWorkManager.Current.EnableFilter(AbpDataFilters.MayHaveTenant); _unitOfWorkManager.Current.SetFilterParameter(AbpDataFilters.MayHaveTenant, AbpDataFilters.Parameters.TenantId, 1); //Save user CheckErrors(await _userManager.UpdateAsync(_user)); await _unitOfWorkManager.Current.SaveChangesAsync(); var callbackUrl = Url.Action("ResetPassword", "Account", new {userId = _user.Id, code = _user.PasswordResetCode}, protocol: Request.Url.Scheme); GmailExtension gmail = new GmailExtension("*****@*****.**", "GOSALES2015"); gmail.SendMessage("Animart Portal Reset Password", "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a> <br/> If this is not you, please inform us by using email to [email protected].", _user.EmailAddress); isActive = _user.IsActive; } return View("ForgotPasswordResult", new ForgotPasswordResultViewModel { EmailAddress = model.EmailAddress, IsActive = isActive, IsEmailConfirmationRequired = true }); } catch (UserFriendlyException ex) { ViewBag.IsMultiTenancyEnabled = _multiTenancyConfig.IsEnabled; ViewBag.ErrorMessage = ex.Message; return View("ForgotPassword", model); } }
public void GivenValidEmailAddressAndPassword() { this.result = true; mailService = new GmailExtension("*****@*****.**", "GOSALES2015"); }
public bool InsertExpeditionAdjustment(string id, string name) { try { var poId = Guid.Parse(id); var po = _purchaseOrderRepository.GetAll().FirstOrDefault(e => e.Id == poId); //var exAdjustment = _shipmentCostRepository.GetAll().FirstOrDefault( // e => e.Expedition.ToLower() == name.Trim().ToLower()); if ( po!=null)//exAdjustment != null && { po.ExpeditionAdjustment = name.Trim(); _purchaseOrderRepository.Update(po); string breakLine = "<br/>"; GmailExtension gmail = new GmailExtension(ANIMART_EMAILADDRESS, ANIMART_PASSWORD); gmail.SendMessage("Purchase Order " + po.Id.ToString() + " Has been updated", "Dear retailer," + breakLine + breakLine + "The expedition for your purchase order with number:" + po.Id.ToString() + " has been updated to \"" + name + "\"." + breakLine + breakLine + "Please kindly login to your account to check the status of the orders." + breakLine + breakLine + "Thank you", po.CreatorUser.EmailAddress); return true; } else return false; } catch (Exception ex) { return false; } }
public bool InsertInvoiceReceiptNumber(string id, string receipt, List<OrderItemDto> orderItems) { try { var poId = Guid.Parse(id); var po = _purchaseOrderRepository.GetAll().FirstOrDefault(e => e.Id == poId); orderItems= orderItems.Where(e => e.Checked).ToList(); for (int i = 0; i < orderItems.Count; i++) { var orderId = orderItems[i].Id; var ord =_orderItemRepository.FirstOrDefault(e=>e.Id==orderId); ord.Status = "DONE"; _orderItemRepository.Update(ord); } var invoices = orderItems.Select(e => e.Invoice).Distinct().ToList(); for (int i = 0; i < invoices.Count(); i++) { var invId = invoices[i].Id; var inv = _invoiceRepository.FirstOrDefault(e=>e.Id== invId); if (inv != null) { inv.ResiNumber = receipt; _invoiceRepository.Update(inv); string breakLine = "<br/>"; GmailExtension gmail = new GmailExtension(ANIMART_EMAILADDRESS, ANIMART_PASSWORD); gmail.SendMessage("Invoice Number " + inv.InvoiceNumber + " Has been updated", "Dear retailer," + breakLine + breakLine + "Your invoice with number:" + inv.InvoiceNumber + " has been updated to \"" + "DONE" + "\"." + breakLine + breakLine + "Your shipment tracking number is: \"" + inv.ResiNumber + "\"." + breakLine + "To track your shipment, use the corresponding couriers service website or contact by phone." + breakLine + breakLine + "Thank you", po.CreatorUser.EmailAddress); } } return true; } catch (Exception ex) { return false; } }
public bool InsertReceiptNumber(string id, string receipt) { try { string breakLine = "<br/>"; var poid = Guid.Parse(id); var po = _purchaseOrderRepository.GetAll().FirstOrDefault(e => e.Id == poid); po.ReceiptNumber = receipt; po.Status = "DONE"; _purchaseOrderRepository.Update(po); GmailExtension gmail = new GmailExtension(ANIMART_EMAILADDRESS, ANIMART_PASSWORD); gmail.SendMessage("Purchase Order " + po.Id.ToString() + " Has been updated", "Dear retailer,"+breakLine+breakLine+ "Your purchase order with number:" + po.Id.ToString() + " has been updated to \"" + po.Status +"\"."+breakLine+breakLine + "Your shipment tracking number is: \"" + po.ReceiptNumber+"\"."+ breakLine + "To track your shipment, use the corresponding couriers service website or contact by phone."+ breakLine+breakLine + "Thank you", po.CreatorUser.EmailAddress); return true; } catch (Exception ex) { return false; } }
public bool UpdateOrderItemStatus(string id, string status, List<InvoiceInputDto> orderItems) { try { var POid = Guid.Parse(id); var po = _purchaseOrderRepository.GetAll().FirstOrDefault(e => e.Id == POid); po.Status = status; _purchaseOrderRepository.Update(po); for (int i = 0; i < orderItems.Count(e=>e.Checked); i++) { var order = orderItems[i]; var data = _orderItemRepository.FirstOrDefault(e=>e.Id== order.Id); data.Status = status; _orderItemRepository.Update(data); } GmailExtension gmail = new GmailExtension(ANIMART_EMAILADDRESS, ANIMART_PASSWORD); string message = ""; string breakLine = "<br/>"; switch (status.Trim().ToLower()) { case "payment": message = "Dear retailer," + breakLine + breakLine + "Your purchase order with number: " + POid + " has been update to \"PAYMENT\"." + breakLine + breakLine + "Please kindly make a bank wire transfer to our account, and upload the bank wire transfer receipt via our system." + breakLine + breakLine + "To check your order details and invoice, you can check it via link: http://shop.animart.co.id/#/orderDetail/" + id + breakLine + breakLine + "Thank you"; break; case "logistic": message = "Dear retailer," + breakLine + breakLine + "Your purchase order with number: " + POid + " has been update to \"LOGISTIC\" for delivery." + breakLine + breakLine + "Please kindly login to your account to check the status of the orders." + breakLine + breakLine + "To check your order details and invoice, you can check it via link: http://shop.animart.co.id/#/orderDetail/" + id + breakLine + breakLine + "Thank you"; break; default: message = " Dear retailer," + breakLine + breakLine + "Your purchase order with number: " + POid + " has been updated to \"" + status + "\"." + breakLine + breakLine + "Please kindly login to your account to check the status of the orders." + breakLine + breakLine + "To check your order details and invoice, you can check it via link: http://shop.animart.co.id/#/orderDetail/" + id + breakLine + breakLine + "Thank you"; break; } gmail.SendMessage("Purchase Order " + POid + " Has been updated", message, po.CreatorUser.EmailAddress); return true; } catch (Exception) { return false; } }
public bool UpdateExpeditionAdjustment(string id, string name, List<OrderItemDto> orderItems) { try { var poId = Guid.Parse(id); var po = _purchaseOrderRepository.GetAll().FirstOrDefault(e => e.Id == poId); var invoices = orderItems.Where(e => e.Checked).Select(e => e.Invoice).Distinct().ToList(); for (int i = 0; i < invoices.Count(); i++) { var invId = invoices[i].Id; var inv = _invoiceRepository.FirstOrDefault(e => e.Id == invId); if (inv != null) { inv.Expedition = name.Trim(); _invoiceRepository.Update(inv); string breakLine = "<br/>"; GmailExtension gmail = new GmailExtension(ANIMART_EMAILADDRESS, ANIMART_PASSWORD); gmail.SendMessage("Invoice Order " + inv.InvoiceNumber + " Has been updated", "Dear retailer," + breakLine + breakLine + "The expedition for your invoice order with number:" + inv.InvoiceNumber + " has been updated to \"" + name + "\"." + breakLine + breakLine + "Please kindly login to your account to check the status of the orders." + breakLine + breakLine + "Thank you", po.CreatorUser.EmailAddress); } } return true; } catch (Exception ex) { return false; } }