public void Registered( [ARDataBind("Instance", AutoLoadBehavior.NewRootInstanceIfInvalidKey)] Payer payer, [DataBind("PaymentOptions")] PaymentOptions paymentOptions, bool showRegistrationCard, string passwordId) { if (payer.Id == 0) { payer.Init(Admin); } payer.AddComment(paymentOptions.GetCommentForPayer()); if (payer.Orgs.Count == 0) { payer.Orgs.Add(new LegalEntity(payer)); } else { var org = payer.Orgs.First(); org.Name = payer.Name; org.FullName = payer.JuridicalName; } if (string.IsNullOrEmpty(payer.Customer)) { payer.Customer = payer.JuridicalName; } DbSession.SaveOrUpdate(payer); var supplier = payer.Suppliers.FirstOrDefault(); var client = payer.Clients.FirstOrDefault(); if (client != null) { Mail().NotifyBillingAboutClientRegistration(client); } else { Mail().PayerRegistred(payer); } if (showRegistrationCard && client != null && client.Users.Count > 0) { Redirect("main", "report", new { id = client.Users.First().Id, passwordId }); } else if (client != null) { RedirectTo(client); } else if (supplier != null) { RedirectTo(supplier); } else { RedirectTo(payer); } }