Example #1
0
        public ActionResult BataEditorUpdate(int id)
        {
            try
            {
                TripViewModel models = new TripViewModel();
                Trip          trip   = _tripService.GetAllTripDetailsById(id);
                if (trip != null)
                {
                    models = AutoMapper.Mapper.Map <TripViewModel>(trip);
                }
                models.Bata = GetBataData();

                if (models.TripBata.Count > 0)
                {
                    TripBataDto tripBata = models.TripBata.Where(a => a.IsDeleted.Equals(false)).LastOrDefault();
                    if (tripBata != null)
                    {
                        BataRate bata = _bataRateService.GetAllBataRates().Where(a => a.Description == tripBata.Description).LastOrDefault();
                        if (bata != null)
                        {
                            models.BataRateId = bata.BataId;
                            models.BataRate   = bata.Amount.ToString();
                        }
                    }
                }
                if (models.CustomBata.Count > 0)
                {
                    CustomBataDto customBata = models.CustomBata.Where(a => a.IsDeleted.Equals(false)).FirstOrDefault();
                    if (customBata != null)
                    {
                        models.AdditionalAmount = customBata.CustomAmount;
                    }
                }
                return(View(models));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        // GET: BataRate
        public ActionResult Index(string message, int?items)
        {
            if (message != null)
            {
                if (message.Equals("Success"))
                {
                    ModelState.AddModelError("", "Successfully deleted " + items + " bata rate(s)");
                }
                else
                {
                    ModelState.AddModelError("", "Please select  bata rate(s) to delete");
                }
            }
            IEnumerable <BataRateViewModel> model = new Collection <BataRateViewModel>();
            IEnumerable <BataRate>          bata  = _bataRateService.GetAllBataRates();

            model = Mapper.Map <IEnumerable <BataRateViewModel> >(bata);
            return(View(model));
        }