예제 #1
0
        public async Task <MealSetRes> SetMeals(MealSetReq objMealSetReq, string ticket)
        {
            MealSetRes objPaxSetRes = new MealSetRes();

            objPaxSetRes = await serviceProxy.PostData(_configuration.GetValue <string>("ServiceMeal:SetMeals"), objMealSetReq, typeof(MealSetRes), ticket);

            return(objPaxSetRes);
        }
예제 #2
0
        public async Task <MealSetRes> SetMealDetailsByID(MealSetReq request)
        {
            MealSetRes   MealSetRes = new MealSetRes();
            UpdateResult resultFlag;
            var          result = _MongoContext.mQuote.AsQueryable().Where(a => a.QRFID == request.QRFID).ToList();

            if (result != null && result.Count > 0)
            {
                var usernm         = request.MealDetails.FirstOrDefault().EditUser;
                var resultposition = _MongoContext.mPosition.AsQueryable().Where(a => a.QRFID == request.QRFID).FirstOrDefault();

                if (resultposition != null)
                {
                    var resultmeal = resultposition;
                    if (resultmeal != null && resultmeal.Meals.Count > 0)
                    {
                        request.MealDetails.FindAll(f => !resultmeal.Meals.Exists(r => r.MealID == f.MealID)).ForEach(m =>
                        {
                            m.EditDate   = DateTime.Now;
                            m.EditUser   = usernm;
                            m.IsDeleted  = true;
                            m.VenueTypes = resultmeal.Meals.Where(d => d.MealID == m.MealID).Select(d => d.VenueTypes).FirstOrDefault();
                        });

                        request.MealDetails.FindAll(f => resultmeal.Meals.Exists(r => r.MealID == f.MealID)).ForEach(m =>
                        {
                            m.EditDate   = DateTime.Now;
                            m.EditUser   = usernm;
                            m.IsDeleted  = false;
                            m.VenueTypes = resultmeal.Meals.Where(d => d.MealID == m.MealID).Select(d => d.VenueTypes).FirstOrDefault();
                        });

                        request.MealDetails.Select(v => v.VenueTypes).FirstOrDefault().ForEach(m => m.VenueTypeName = (m.VenueTypeName == null ? "" : m.VenueTypeName));
                        resultFlag = await _MongoContext.mPosition.UpdateOneAsync(Builders <mPosition> .Filter.Eq("QRFID", request.QRFID),
                                                                                  Builders <mPosition> .Update.Set("Meals", request.MealDetails));

                        MealSetRes.ResponseStatus.Status       = resultFlag.MatchedCount > 0 ? "Success" : "Failure";
                        MealSetRes.ResponseStatus.ErrorMessage = resultFlag.MatchedCount > 0 ? "Meals Details Saved Successfully." : "Meals Details not updated.";
                    }
                }
                else
                {
                    QRFCounterRequest qrfCounterRequest = new QRFCounterRequest();
                    qrfCounterRequest.CounterType = _configuration["CounterType:Meals"].ToString();
                    mPosition objPosition = new mPosition();
                    request.MealDetails.ForEach(m =>
                    {
                        m.CreateDate = DateTime.Now; m.EditDate = null; m.EditUser = "";
                        m.MealID     = m.MealID == 0 ? _genericRepository.GetNextReferenceNumber(qrfCounterRequest).LastReferenceNumber : m.MealID;
                    });
                    objPosition.QRFID = request.QRFID;
                    objPosition.Meals = request.MealDetails;
                    objPosition.Meals[0].CreateUser = request.MealDetails.FirstOrDefault().CreateUser;
                    objPosition.Meals[0].EditDate   = null;
                    objPosition.Meals[0].EditUser   = "";
                    await _MongoContext.mPosition.InsertOneAsync(objPosition);

                    MealSetRes.ResponseStatus.Status       = "Success";
                    MealSetRes.ResponseStatus.ErrorMessage = "Meals Details Saved Successfully.";
                }
            }
            else
            {
                MealSetRes.ResponseStatus.ErrorMessage = "QRF ID not exist.";
            }
            return(MealSetRes);
        }