Пример #1
0
        // GET: /channels/Details/5
        public async Task <ActionResult> Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Channels channels = await _channelsService.GetByIdAsync(id.Value);

            if (channels == null)
            {
                return(HttpNotFound());
            }
            return(View(channels));
        }
Пример #2
0
        public async Task <ActionResult> Create(ResultMessages <schemeViewModel> schemes)
        {
            ResultMessages <schemeViewModel> result = null;

            try
            {
                var routeslist = _routesService.GetQueryable(x => x.Id != null);
                ViewBag.routes = new SelectList(routeslist.ToList(), "Id", "Name");
                //ViewData["RoutesId"] = ViewBag.routes;

                var feeslist = _feesService.GetQueryable(x => x.Id != null);
                ViewBag.fees = new SelectList(feeslist.ToList(), "Id", "Name");

                var channelslist = _channelsService.GetQueryable(x => x.Id != null);
                ViewBag.channels = new SelectList(channelslist.ToList(), "Id", "Name");

                var translist = _transTypeService.GetQueryable(x => x.Id != null);
                ViewBag.trans = new SelectList(translist.ToList(), "Id", "Name");


                if (ModelState.IsValid)
                {
                    schemes.Data.Id = Guid.NewGuid();

                    //db.Schemes.Add(schemes);
                    var channels = await _channelsService.GetByIdAsync(schemes.Data.ChannelId);

                    var fees = await _feesService.GetByIdAsync(schemes.Data.FeesId);

                    var routes = await _routesService.GetByIdAsync(schemes.Data.RoutesId);

                    var transtype = await _transTypeService.GetByIdAsync(schemes.Data.TransTypeId);

                    await _schemeService.SaveAsync(schemes.Data.ConvertToEntityModel(channels, fees, routes, transtype));

                    result      = new ResultMessages <schemeViewModel>();
                    result.Data = schemes.Data;
                    // return RedirectToAction("Index");
                }
            }
            catch (Exception ex)
            {
                result = new ResultMessages <schemeViewModel>(false, ex.Message);
            }

            return(View(result));
        }