public ActionResult Edit(int id)
        {
            WorkcenterDTO workcenterDto = new WorkcenterDTO();

            try
            {
                Workcenter workcenter = workcenterCrudService.Get(id);
                if (workcenter == null)
                {
                    logger.Error($"HttpNotFound! Url:{System.Web.HttpContext.Current.Request.UrlReferrer}");

                    //Dictionary<string, string> statys = new Dictionary<string, string>
                    //{
                    //    ["statys"] = "HttpNotFound"
                    //};

                    //return Json(statys, JsonRequestBehavior.AllowGet);
                    return(HttpNotFound());
                }
                else
                {
                    workcenterDto = AutoMapperWebUtil.WorkcenterEntitiesToDto(workcenter);
                }
            }
            catch (ValidationException ex)
            {
                ControllerExtension.ActionsOnException(logger, ex, ModelState);
                return(Json(ex, JsonRequestBehavior.AllowGet));
            }
            // workcenterViewModel.ModelState = this.ModelState;
            return(Json(workcenterDto, JsonRequestBehavior.AllowGet));
        }
        public async Task <ActionResult> Detail(int id)
        {
            UserViewModel model = new UserViewModel();

            var response = await _crudService.Get <UserModel>(id, Token, UserService.UserEntity);

            if (response.Success)
            {
                if (MyUser.CompanyId == response.Value.CompanyId || User.IsInRole(RoleSuperAdmin))
                {
                    model.Id        = response.Value.Id;
                    model.Username  = response.Value.Username;
                    model.Firstname = response.Value.Firstname;
                    model.Lastname  = response.Value.Lastname;
                    model.Email     = response.Value.Email;
                    model.Admin     = response.Value.Admin;
                }
                else
                {
                    model.CanView = false;
                    AddMessageToModel(model, "You cannot display this user, because this user belongs to different company!");
                }
            }
            else
            {
                AddMessageToModel(model, response.Message);
            }

            return(View(model));
        }
        public async Task <IActionResult> View(int id)
        {
            try
            {
                Tourcost tourcost = _tourcostCrudService.Get(id);

                var user = await _userManager.FindByIdAsync(tourcost.CreatedBy);

                tourcost.CreatedBy = user.UserName;

                tourcost.TourcostDetail = _tourcostDetailCrudService.GetAll(p => p.TourcostId == id).ToList();
                tourcost.Guide          = _guideCrudService.Get(p => p.Id == tourcost.GuideId);

                tourcost.LowerTransport = _transportCrudService.Get(p => p.MinPAX <= tourcost.MinPAX && p.MaxPAX >= tourcost.MinPAX).Name;
                tourcost.UpperTransport = _transportCrudService.Get(p => p.MinPAX <= tourcost.MaxPAX && p.MaxPAX >= tourcost.MaxPAX).Name;

                foreach (var tourdetail in tourcost.TourcostDetail)
                {
                    tourdetail.Sector1 = _sectorCrudService.Get(tourdetail.Sector1Id);
                    tourdetail.Sector1.SectorTransport = _sectorTransportCrudService.GetAll(p => p.SectorId == tourdetail.Sector1Id).ToList();

                    if (tourdetail.Sector2Id != null)
                    {
                        tourdetail.Sector2 = _sectorCrudService.Get(tourdetail.Sector2Id);
                        tourdetail.Sector2.SectorTransport = _sectorTransportCrudService.GetAll(p => p.SectorId == tourdetail.Sector2Id).ToList();
                    }

                    if (tourdetail.Sector3Id != null)
                    {
                        tourdetail.Sector3 = _sectorCrudService.Get(tourdetail.Sector3Id);
                        tourdetail.Sector3.SectorTransport = _sectorTransportCrudService.GetAll(p => p.SectorId == tourdetail.Sector3Id).ToList();
                    }

                    if (tourdetail.HotelAId != null)
                    {
                        tourdetail.HotelA = _hotelCrudService.Get(tourdetail.HotelAId);
                        tourdetail.HotelA.HotelRoomRate = _hotelRoomRateCrudService.Get(p => p.HotelId == tourdetail.HotelAId);
                    }

                    if (tourdetail.HotelBId != null)
                    {
                        tourdetail.HotelB = _hotelCrudService.Get(tourdetail.HotelBId);
                        tourdetail.HotelB.HotelRoomRate = _hotelRoomRateCrudService.Get(p => p.HotelId == tourdetail.HotelBId);
                    }

                    if (tourdetail.HotelCId != null)
                    {
                        tourdetail.HotelC = _hotelCrudService.Get(tourdetail.HotelCId);
                        tourdetail.HotelC.HotelRoomRate = _hotelRoomRateCrudService.Get(p => p.HotelId == tourdetail.HotelCId);
                    }
                }

                return(View(tourcost));
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Esempio n. 4
0
        public void EditShouldReturnCreateView()
        {
            A.CallTo(() => countryCrudSrv.Get(1)).Returns(A.Fake <Country>());

            countryController.Edit(1).ShouldBePartialViewResult().ShouldBeCreate();

            A.CallTo(() => countryCrudSrv.Get(1)).MustHaveHappened();
        }
Esempio n. 5
0
        public ActionResult Create(int id, DateTime ArrivalDate, DateTime DepartureDate)
        {
            CreateReservationVm model = new CreateReservationVm();

            model.RoomType   = _mapper.Map <RoomTypeVm>(_roomTypeCrudService.Get(id));
            model.TotalPrice = (DepartureDate - ArrivalDate).Days * model.RoomType.Price;
            return(View(model));
        }
Esempio n. 6
0
        /// <summary>
        /// Retourne une permission grâce à son ID
        /// </summary>
        /// <param name="permissionId"></param>
        /// <returns></returns>
        public virtual PermissionRecord GetPermissionRecordById(int permissionId)
        {
            if (permissionId == 0)
            {
                return(null);
            }

            return(_permissionRecordRepository.Get(x => x.Id == permissionId).FirstOrDefault());
        }
Esempio n. 7
0
        public ActionResult Edit(Animal animal)
        {
            _elasticService.DeleteAnimal(animal.Id);

            MedicalData medicalData = _medicalDataService.Get(Int32.Parse(_animalMedicalDataService.Get(x => x.Id_animal == animal.Id.ToString()).OrderByDescending(x => x.CreatedOnUtc).FirstOrDefault().Id_MedicalData));

            _elasticService.IndexAnimal(animal, null);
            _crudService.Update(animal);
            return(RedirectToAction("Index"));
        }
Esempio n. 8
0
        public ActionResult Create(TCreateInput input)
        {
            if (!ModelState.IsValid)
            {
                return(View(input));
            }
            var id = service.Create(createMapper.MapToEntity(input, new TEntity()));
            var e  = service.Get(id);

            return(Json(new { Content = this.RenderView(RowViewName, new[] { e }) }));
        }
        public ActionResult Create(CountryInput input)
        {
            if (ModelState.IsValid)
            {
                var country = mapper.Map <CountryInput, Country>(input);
                var id      = countryService.Create(country);
                country = countryService.Get(id);

                return(Json(new { Item = country }));
            }

            return(Json(ModelState.GetErrorsInline()));
        }
Esempio n. 10
0
        public List <PersonDTO> Get()
        {
            var people = _personService.Get();

            var personDTOs = people.Select(x => new PersonDTO
            {
                Id    = x.Id,
                Name  = x.Name,
                Cards = new List <CardDTO>()
            })
                             .ToList();

            return(personDTOs);
        }
Esempio n. 11
0
        public List <SportDTO> Get()
        {
            var sports = _sportService.Get();

            var sportDTOs = sports.Select(x => new SportDTO
            {
                Id    = x.Id,
                Name  = x.Name,
                Cards = new List <CardDTO>()
            })
                            .ToList();

            return(sportDTOs);
        }
Esempio n. 12
0
        public List <TeamDTO> Get()
        {
            var teams = _teamService.Get();

            var teamDTOs = teams.Select(x => new TeamDTO
            {
                Id    = x.Id,
                Name  = x.Name,
                Cards = new List <CardDTO>()
            })
                           .ToList();

            return(teamDTOs);
        }
        public List <CollegeDTO> Get()
        {
            var colleges = _collegeService.Get();

            var collegeDTOs = colleges.Select(x => new CollegeDTO
            {
                Id    = x.Id,
                Name  = x.Name,
                Cards = new List <CardDTO>()
            })
                              .ToList();

            return(collegeDTOs);
        }
Esempio n. 14
0
        public ActionResult Create(TCreateInput input)
        {
            if (!ModelState.IsValid)
            {
                return(View(input));
            }

            var entity = createMapper.MapToEntity(input, new TEntity());
            var id     = service.Create(entity);

            entity = service.Get(id);


            return(RedirectToAction("Index"));
        }
Esempio n. 15
0
        public IActionResult Index(int animalId)
        {
            int         animalMedicalDataId = Int32.Parse(_animalMedicalDataService.Get(z => Int32.Parse(z.Id_animal) == animalId).FirstOrDefault().Id_MedicalData);
            MedicalData medicalData         = _medicalDataService.Get(x => x.Id == animalMedicalDataId).FirstOrDefault();

            MedicalDataModel model = new MedicalDataModel();

            if (medicalData == null)
            {
                return(View(model));
            }

            model.AnimalId  = animalId;
            model.Id        = medicalData.Id;
            model.Allergies = medicalData.Allergies;
            model.Chiped    = medicalData.Chiped;
            model.Hair      = medicalData.Hair;
            model.Race      = medicalData.Race;
            model.Size      = medicalData.Size;
            model.Species   = medicalData.Species;
            model.Vaccines  = medicalData.Vaccines;
            model.Weaned    = medicalData.Weaned;
            model.Weight    = medicalData.Weight;
            model.Report    = "";

            return(View(model));
        }
Esempio n. 16
0
        public IActionResult Index(int id)
        {
            AnimalDetails model     = new AnimalDetails();
            var           medDataId = Int32.Parse(_animalMedicalDataService.Get(amd => amd.Id_animal == id.ToString()).OrderBy(z => z.CreatedOnUtc).LastOrDefault().Id_MedicalData);

            if (medDataId != null)
            {
                MedicalData medicalData = _medicalDataService.Get(x => x.Id == medDataId).FirstOrDefault();
                model.HairType = medicalData.Hair;
                model.Race     = medicalData.Race;
            }

            Animal a = _animalService.Get(x => x.Id == id).FirstOrDefault();

            model.Age       = a.Age;
            model.Birthday  = a.Birthday;
            model.Character = a.Character;
            model.nom       = a.Name;
            model.Pedigree  = a.Pedigree;
            model.Price     = a.Price;
            model.Robe      = a.Robe;
            model.sexe      = a.Sexe;
            model.Type      = a.Type;
            model.Weight    = a.Weight;
            return(View());
        }
Esempio n. 17
0
        public TeamIndex Build(TeamFilterOptionsViewModel filterOptionsVM)
        {
            var teamSearchFilterOptions = SearchFilterService.BuildTeamSearchFilterOptions(filterOptionsVM);

            if (teamSearchFilterOptions == null)
            {
                teamSearchFilterOptions = new TeamSearchFilterOptions();
            }
            var teamSearch = _teamSearchService.Get(teamSearchFilterOptions);
            var sports     = _sportService.Get();
            var leagues    = _leagueService.Get();
            var teamList   = teamSearch.Teams.Select(x => new TeamListItemViewModel
            {
                Id          = x.Id,
                Name        = x.ToString(),
                LeagueName  = x.League != null? x.League.Name : "",
                SportName   = x.Sport != null ? x.Sport.Name : "",
                CollegeId   = x.College != null ? x.College.Id : 0,
                CollegeName = x.College != null ? x.College.Name : ""
            })
                             .ToList();

            var teamSearchViewModel = new TeamIndex
            {
                TeamFilterOptionsViewModel = filterOptionsVM,
                Teams   = teamList,
                Sports  = MvcService.BuildSportsSelectList(sports, teamSearchFilterOptions.SportId ?? 0),
                Leagues = MvcService.BuildLeaguesSelectList(leagues, teamSearchFilterOptions.LeagueId ?? 0)
            };

            return(teamSearchViewModel);
        }
Esempio n. 18
0
        public TeamEdit Build(int id)
        {
            var team = _teamService.Get(id);

            var sports   = MvcService.BuildSportsSelectList(_sportService.Get(), team.Sport != null ? team.Sport.Id : 0);
            var leagues  = MvcService.BuildLeaguesSelectList(_leagueService.Get(), team.League != null ? team.League.Id : 0);
            var colleges = MvcService.BuildCollegesSelectList(_collegeService.Get(), team.College != null ? team.College.Id : 0);

            var vm = new TeamEdit
            {
                DisplayName = team.ToString(),
                Sports      = sports,
                Leagues     = leagues,
                Colleges    = colleges,
                TeamVM      = new TeamViewModel
                {
                    Id          = team.Id,
                    Identifier  = team.Identifier,
                    City        = team.City,
                    Nickname    = team.Nickname,
                    NotableFlag = team.NotableFlag,
                    CollegeId   = team.College == null ? 0 : team.College.Id,
                    SportId     = team.Sport == null ? 0 : team.Sport.Id,
                    LeagueId    = team.League == null ? 0 : team.League.Id
                }
            };

            return(vm);
        }
Esempio n. 19
0
        public ActionResult <IEnumerable <UserDto> > Get()
        {
            try
            {
                var users = service.Get();
                if (users is null)
                {
                    users = new List <UserEntity>();
                }

                return(Ok(mapper.Map <IEnumerable <UserEntity>, IEnumerable <UserDto> >(users)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 20
0
        public ActionResult Create(TCreateInput input, bool?usingAjaxList)
        {
            if (!ModelState.IsValid)
            {
                return(View(input));
            }

            var id     = service.Create(mapper.Map <TCreateInput, TEntity>(input));
            var entity = service.Get(id);

            if (usingAjaxList.HasValue)
            {
                return(Json(new { Content = this.RenderView(RowViewName, new[] { entity }) }));
            }

            return(Json(MapEntityToGridModel(entity)));
        }
Esempio n. 21
0
        public ActionResult <IEnumerable <GroupDto> > Get()
        {
            try
            {
                var groups = service.Get();
                if (groups is null)
                {
                    groups = new List <GroupEntity>();
                }

                return(Ok(mapper.Map <IEnumerable <GroupEntity>, IEnumerable <GroupDto> >(groups)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 22
0
        public ActionResult Edit(int id)
        {
            RoomDetailsVm model = _mapper.Map <RoomDetailsVm>(_roomCrudService.Get(id));

            model.RoomTypes = new SelectList(_roomTypeCrudService.GetAll(), "Id", "Name");

            return(View("Details", model));
        }
Esempio n. 23
0
        public ActionResult <IEnumerable <AlbumDto> > Get()
        {
            try
            {
                var albums = service.Get();
                if (albums is null)
                {
                    albums = new List <AlbumEntity>();
                }

                return(Ok(mapper.Map <IEnumerable <AlbumEntity>, IEnumerable <AlbumDto> >(albums)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 24
0
        public ActionResult Edit(int id)
        {
            RoomTypeDto       type  = _roomTypeCrudService.Get(id);
            RoomTypeDetailsVm model = _mapper.Map <RoomTypeDetailsVm>(type);

            model.AvailableConveniences = new MultiSelectList(_convenienceCrudService.GetAll(), "Id", "Name", type.Conveniences);

            return(View("Details", model));
        }
Esempio n. 25
0
        public IActionResult Update(Guid visitId)
        {
            var visit = new Visit();

            try
            {
                ViewBag.sm         = new SelectList(_clientCrudService.GetAll(), "Id", "Name");
                visit              = _crudService.Get(visitId);
                ViewBag.ClientName = _clientCrudService.GetAll().Select(x => x.Name).ToList();
                ViewBag.Masters    = _masterServiceCrudService.GetAll().Select(x => x.Master.FullName).Distinct().ToList();
                ViewBag.Service    = _masterServiceCrudService.GetAll().Where(x => x.Master.FullName == ViewBag.Masters[0]).Select(x => x.Service.NameOfService).ToList();
            }
            catch (ServiceOperationException exception)
            {
                ViewBag.Error = ErrorFactory.IdentifyExceptionByType(exception).Description;
            }
            return(View(visit));
        }
        public IActionResult Get(Guid visitId)
        {
            var servicesInVisit = new List <ServiceInVisit>();

            try
            {
                servicesInVisit.AddRange(_serviceInVisitCrudService.GetInVisit(visitId));
            }
            catch (ServiceOperationException exception)
            {
                ViewBag.Error = ErrorFactory.IdentifyExceptionByType(exception).Description;
            }
            ViewBag.VisitId = visitId;
            var visit = _crudService.Get(visitId);

            ViewBag.TotalCost = visit.TotalCost;
            ViewBag.Date      = visit.DateOfVisit;
            return(View(servicesInVisit));
        }
Esempio n. 27
0
        public virtual IActionResult Get(long id)
        {
            var m = _crudService.Get(id);

            if (m == null)
            {
                return(NotFound());
            }

            return(Ok(new DataResponse <T>(m)));
        }
Esempio n. 28
0
        public IActionResult Create(Visit visit)
        {
            //DateOfVisitDateValidation dateOfVisitDateValidation = new DateOfVisitDateValidation();
            if (ModelState.IsValid)
            {
                var createdVisit = new List <Visit>();

                try
                {
                    createdVisit.Add(_crudService.Create(visit));
                }
                catch (ServiceOperationException exception)
                {
                    ViewBag.Error = ErrorFactory.IdentifyExceptionByType(exception).Description;
                    return(View(createdVisit));
                }
                return(RedirectToAction("Get", "ServicesInVisits", new { visitId = visit.Id }));
            }
            visit.Client = _clientCrudService.Get(visit.ClientId);
            return(View(visit));
        }
Esempio n. 29
0
        public async Task <IActionResult> Get(string fileCodeNo)
        {
            try
            {
                if (fileCodeNo == null)
                {
                    var result = await _customerCrudService.GetAllAsync();

                    return(Json(result.OrderByDescending(p => p.CreatedDate)));
                }
                else
                {
                    var result = _customerCrudService.Get(p => p.FileCodeNo == fileCodeNo);
                    return(Json(result));
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
        public async Task <IActionResult> Get(int?id)
        {
            try
            {
                if (id == null)
                {
                    var result = await _transportCrudService.GetAllAsync();

                    return(Json(result));
                }
                else
                {
                    var result = _transportCrudService.Get(id);
                    return(Json(result));
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }