public Profile GetById(int Id) { return(_profilesRepository.GetById(Id)); }
public ActionResult UpdateLimitSuccess(string operation_xml, string signature) { string message = string.Format(Translation.Translation.UpdateFail, ConfigurationManager.AppSettings["ContactNumbers"]); User authenticatedUser = _userRepository.GetUserByPhone(User.Identity.Name); if (authenticatedUser != null) { string signatureFromAnswer = LiqPay.GetSignFromAnswer(operation_xml); if (signatureFromAnswer == signature) { Order order = new Order(); XmlDocument doc = new XmlDocument(); doc.LoadXml(LiqPay.GetOperationXmlFromAnswer(operation_xml)); XmlNode nodeOrderId = doc.SelectSingleNode("response/order_id"); if (nodeOrderId != null) { order.OrderId = Guid.Parse(nodeOrderId.InnerText); } XmlNode nodeGoodId = doc.SelectSingleNode("response/goods_id"); if (nodeGoodId != null) { order.ProfileId = int.Parse(nodeGoodId.InnerText); } XmlNode nodeAmmount = doc.SelectSingleNode("response/amount"); if (nodeAmmount != null) { order.Ammount = decimal.Parse(nodeAmmount.InnerText); } XmlNode nodeStatus = doc.SelectSingleNode("response/status"); if (nodeStatus != null) { order.Status = nodeStatus.InnerText; } order.User = authenticatedUser; order.Created = DateTime.Now; _ordersRepository.Add(order); _ordersRepository.SaveChanges(); if (order.Status == "success") { Profile profile = _profilesRepository.GetById(order.ProfileId); authenticatedUser.Profile = profile; if (authenticatedUser.ProfileExpires.HasValue) { authenticatedUser.ProfileExpires = authenticatedUser.ProfileExpires.Value.AddMonths(1); } else { authenticatedUser.ProfileExpires = DateTime.Now.AddMonths(1); } IEnumerable <Announcement> addAnnouncements = authenticatedUser.Apartments.OrderByDescending(an => an.Created).Skip(profile.MaxAnnouncements); foreach (Announcement announcement in addAnnouncements) { announcement.IsVisible = true; } foreach (Announcement announcement in authenticatedUser.Apartments) { IEnumerable <Photo> addPhotos = announcement.Photos.OrderByDescending(p => p.Created).Skip(profile.MaxPhotosPerAnnouncements); foreach (Photo photo in addPhotos) { photo.IsVisible = true; } } _userRepository.SaveChanges(); message = Translation.Translation.UpdateSuccess; } } } TempData["UpdateLimitSuccessMessage"] = message; return(RedirectToAction("UpdateLimit")); }