public string Result(decimal OutSum, int InvId, string SignatureValue, int ShpAdId, int ShpPremiumId, int ShpSectionId, CategorySearch ShpSiteCategory) { var paymentModel = new PaymentViewModel(OutSum, InvId, ShpAdId, ShpPremiumId, ShpSectionId, ShpSiteCategory); var hash = paymentModel.GenerateHash2().Trim().ToUpper(); SignatureValue = SignatureValue.Trim().ToUpper(); var payment = new Payment() { AdId = ShpAdId, Cost = OutSum, CreatedAt = DateTime.Now, PaysystemInvId = InvId, SiteCategory = ShpSiteCategory, PremiumId = ShpPremiumId, SectionId = ShpSectionId }; if (!hash.Equals(SignatureValue)) { payment.Status = PaymentStatus.ErrorBySign; _paymentRepository.Save(payment); return("oops"); } var payedPremium = _premiumRepository.Read(ShpPremiumId); if (payedPremium.Cost != OutSum) { payment.Status = PaymentStatus.ErrorBySum; _paymentRepository.Save(payment); return("oops by sum"); } payment.Status = PaymentStatus.Success; _paymentRepository.Save(payment); var premium = _premiumRepository.Read(ShpPremiumId); switch (ShpSiteCategory) { case CategorySearch.Announcement: var adsPremiumsRepository = _announcementsPremiumsRefRepository; var adsPremiumsRef = new AnnouncementsPremiumsRef(); adsPremiumsRef.AdId = ShpAdId; adsPremiumsRef.AdSectionId = ShpSectionId; adsPremiumsRef.CreatedAt = DateTime.Now; adsPremiumsRef.ExpiresAt = DateTime.Now.AddHours(premium.Lifetime); adsPremiumsRef.PremiumId = ShpPremiumId; try { adsPremiumsRepository.Save(adsPremiumsRef); } catch (Exception e) { return("oops by database"); } break; case CategorySearch.Realty: // TODO: Paste a realtyPremiumsRef repository here break; default: return("oops local repository"); break; } return(string.Format("OK{0}", InvId)); }