Exemplo n.º 1
0
        public IActionResult CreateYachtTourCharter(YachtTourCharterCreateModel model)
        {
            var result   = _yachtTourService.CreateYachtTourCharter(model);
            var response = new BaseResponse <YachtTourCharterResultModel>();

            response = BaseResponse <YachtTourCharterResultModel> .Success(result);

            return(Ok(response));
        }
        public async Task <IActionResult> CreateTourCharterFromOriginSourceAsync([FromBody] YachtTourCharterCreateModel model)
        {
            var result = await _yachtTourCharterService.CreateCharterFromOriginSource(model);

            if (result.IsSuccessStatusCode)
            {
                return(Ok(result));
            }
            return(BadRequest());
        }
Exemplo n.º 3
0
        public YachtTourCharterResultModel CreateYachtTourCharter(YachtTourCharterCreateModel model)
        {
            using (var trans = _yachtDbContext.Database.BeginTransaction())
            {
                try
                {
                    var result = new YachtTourCharterResultModel();

                    var tourPrice = _yachtDbContext.YachtTourPricings.AsNoTracking()
                                    .Where(x => x.TourFid == model.YachtTourFid && x.YachtFid == model.YachtFid && x.EffectiveDate <= DateTime.Now && DateTime.Now <= x.EffectiveEndDate)
                                    .OrderBy("CreatedDate DESC").FirstOrDefault();

                    //Insert into the table yachttourcharters
                    var yachtTourCharter = new YachtTourCharters();
                    yachtTourCharter                     = _mapper.Map <YachtTourCharterCreateModel, YachtTourCharters>(model, yachtTourCharter);
                    yachtTourCharter.UniqueId            = UniqueIDHelper.GenarateRandomString(12);
                    yachtTourCharter.SourceResKey        = "TEMP";
                    yachtTourCharter.IsExistingCustomer  = true;
                    yachtTourCharter.YachtPortFid        = 0;
                    yachtTourCharter.DateFrom            = DateTime.Now;
                    yachtTourCharter.DateTo              = DateTime.Now;
                    yachtTourCharter.BookingDate         = DateTime.Now;
                    yachtTourCharter.StatusFid           = (int)YachtCharterStatusEnum.Waiting;
                    yachtTourCharter.Processed           = true;
                    yachtTourCharter.GotSpecialRequest   = false;
                    yachtTourCharter.PaymentExchangeRate = 0;

                    if (tourPrice != null)
                    {
                        yachtTourCharter.CultureCode  = tourPrice.CultureCode;
                        yachtTourCharter.CurrencyCode = tourPrice.CurrencyCode;
                    }

                    _yachtDbContext.YachtTourCharters.Add(yachtTourCharter);
                    _yachtDbContext.SaveChanges();

                    //Insert into the table yachttourcharterdetail
                    var yachtTourCharterDetail = new YachtTourCharterDetails();
                    yachtTourCharterDetail.TourCharterFid = yachtTourCharter.Id;

                    //Insert into the table yachttourcharterpaymentlogs
                    var yachtTourCharterPaymentLog = new YachtTourCharterPaymentLogs();
                    yachtTourCharterPaymentLog.TourCharterFid = yachtTourCharter.Id;
                    yachtTourCharterPaymentLog.PaymentDate    = DateTime.Now;
                    yachtTourCharterPaymentLog.PaymentAmount  = yachtTourCharter.PaymentValue;
                    yachtTourCharterPaymentLog.StatusFid      = yachtTourCharter.StatusFid;
                    _yachtDbContext.YachtTourCharterPaymentLogs.Add(yachtTourCharterPaymentLog);
                    _yachtDbContext.SaveChanges();

                    trans.Commit();
                    trans.Dispose();

                    result.UniqueId     = yachtTourCharter.UniqueId;
                    result.CultureCode  = yachtTourCharter.CultureCode;
                    result.CurrencyCode = yachtTourCharter.CurrencyCode;
                    result.PrepaidValue = yachtTourCharter.PrepaidValue;

                    return(result);
                }
                catch
                {
                    trans.Rollback();
                    trans.Dispose();
                    throw;
                }
            }
        }