public GiftCardRedemptionStatusModal HandleGiftCardRedemption(GiftCardRedemptionModal giftCardRedemptionModal) { var responseModal = new GiftCardRedemptionStatusModal(); try { var giftCardRedemption = new GiftCardRedemption { AmounOfRedemption = giftCardRedemptionModal.AmounOfRedemption, OrderNumber = giftCardRedemptionModal.OrderNumber, GiftCardCode = giftCardRedemptionModal.GiftCardCode, CustomerId = giftCardRedemptionModal.CustomerId, RedemptionDateTime = DateTime.Now }; var giftCardObject = _scottybonsEComEntities.GiftCards.FirstOrDefault(gc => gc.GiftCardCode.ToLower().Trim().Equals(giftCardRedemptionModal.GiftCardCode.ToLower().Trim())); if (!ReferenceEquals(giftCardObject, null)) { giftCardObject.CurrentGiftCardValue = (giftCardObject.CurrentGiftCardValue - giftCardRedemptionModal.AmounOfRedemption); _scottybonsEComEntities.SaveChanges(); //Logic to update Orders table [OrderstatusId, PaymentMethodId, Payment Date]. int oID = Convert.ToInt32(giftCardRedemptionModal.OrderNumber); var order = _scottybonsEComEntities.Orders.FirstOrDefault(c => c.OrderID == oID); order.OrderStatusID = 4; _scottybonsEComEntities.SaveChanges(); } else { responseModal.Status = true; return(responseModal); } _scottybonsEComEntities.GiftCardRedemptions.Add(giftCardRedemption); _scottybonsEComEntities.SaveChanges(); responseModal.Status = true; return(responseModal); } catch (Exception ex) { responseModal.Status = false; return(responseModal); } }
public GiftCardRedemptionStatusModal HandleGiftCardRedemption(GiftCardRedemptionModal modal) { return(giftCardServices.HandleGiftCardRedemption(modal)); }