/// <summary> /// Guarda en el sistema de promociones las promociones de regalo /// </summary> /// <param name="ReceiptID"></param> /// <param name="ChangeBy"></param> /// <param name="UserID"></param> /// <history> /// [vipacheco] 27/Mayo/2016 Created /// </history> public async static Task <string> SavePromotionsSistur(int ReceiptID, string UserID, string ChangeBy = "") { return(await Task.Run(async() => { List <GiftType> aGifts = new List <GiftType>(); List <GuardaPromocionForzadaRequest> aPromotions = new List <GuardaPromocionForzadaRequest>(); GuardaPromocionForzadaRequest Request = null; GuardaPromocionForzadaResponse Response = null; string GiftsSaved = string.Empty; string GiftsNoSaved = string.Empty; // obtenemos los regalos de promociones de Sistur aPromotions = await GetGiftsPromotionsSistur(ReceiptID, ChangeBy, UserID, aGifts); // si algun regalo tiene promociones de Sistur if (aPromotions != null) { if (aPromotions.Count > 0) { for (int i = 0; i <= aPromotions.Count - 1; i++) { Request = aPromotions[i]; // Invocamos al servicio web para insertar cada regalo que se pretende asignar Response = await GuardarPromocionForzada(Request); // si se guardo exitosamente en Sistur if (!Response.hasErrors) { // actualizamos los regalos para identificarlos como que se guardaron en Sistur BRGiftsReceiptDetail.UpdateGiftPromotionSistur(aGifts[i].Receipt, aGifts[i].ID, aGifts[i].Promotion); GiftsSaved += aGifts[i].Descripcion + "\r\n"; } else { GiftsNoSaved += aGifts[i].Descripcion + "\r\n"; } } // si se pudo guardar todas las promociones if (string.IsNullOrEmpty(GiftsNoSaved)) { return "Gifts were successfully saved in Sistur as Promotion"; } // si no se pudo guardar ninguna promocion else if (string.IsNullOrEmpty(GiftsSaved)) { return "None gift was saved in Sistur as Promotion"; } // si no se pudo guardar alguna promocion else { return "The following gifts were saved in Sistur as Promotion:\r\n" + GiftsSaved + "\r\n\r\n" + "But the following gifts were not saved: \r\n" + GiftsNoSaved; } } } return string.Empty; } )); }
/// <summary> /// Agrega una promocion /// </summary> /// <param name="Promotions"></param> /// <param name="Hotel"></param> /// <param name="Folio"></param> /// <param name="Promotion"></param> /// <param name="GiftID"></param> /// <param name="ReceiptID"></param> /// <param name="User"></param> /// <param name="enumPromotionsSystem"></param> /// <history> /// [vipacheco] 27/Mayo/2016 Created /// [vipacheco] 23/Agosto/2016 Modified -> se cambio el tipo del parametro Promotions /// </history> public static void AddPromotion(ref List <GuardaPromocionForzadaRequest> Promotions, string Hotel, string Folio, string Promotion, string GiftID, int ReceiptID, string User, EnumPromotionsSystem enumPromotionsSystem) { GuardaPromocionForzadaRequest request = new GuardaPromocionForzadaRequest() { hotel = Hotel, folio = Folio, adicional = (enumPromotionsSystem == EnumPromotionsSystem.PVP) ? "1" : "0", idpromo = Promotion, GiftID = GiftID, GiftsReceiptID = $"{ReceiptID}", usralta = User, fechaalta = BRHelpers.GetServerDate(), idtipoasignacion = "CONT", status = "A", tipomov = "", usrmodif = "" }; Promotions.Add(request); }
/// <summary> /// Guarda una promocion /// </summary> /// <param name="Request"></param> /// <param name="Error"></param> /// <returns></returns> /// <history> /// [vipacheco] 27/Mayo/2016 Created /// </history> private async static Task <GuardaPromocionForzadaResponse> GuardarPromocionForzada(GuardaPromocionForzadaRequest Request) { return(await Task.Run(() => { GuardaPromocionForzadaResponse Response = new GuardaPromocionForzadaResponse(); // invocamos al servicio web Response = Current().GuardarPromocionForzada(Request); // Si ocurrio un error if (Response.hasErrors) { throw new Exception(Response.errorInfo); } return Response; })); }