コード例 #1
0
        public JsonResult GetHall(int hallId)
        {
            JsonResponseModel result = new JsonResponseModel();

            try
            {
                if (hallId > 0)
                {
                    _hallLogic = new HallLogic();
                    HALL hall = _hallLogic.GetEntityBy(c => c.Id == hallId);

                    if (hall != null)
                    {
                        result.HallId          = hall.Id;
                        result.HallName        = hall.Name;
                        result.HallDescription = hall.Description;
                    }

                    result.IsError = false;
                }
                else
                {
                    result.IsError = true;
                    result.Message = "Invalid parameter";
                }
            }
            catch (Exception ex)
            {
                result.IsError = true;
                result.Message = ex.Message;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
ファイル: Utility.cs プロジェクト: ifeanyilawrence/Attendance
        public static List <SelectListItem> PopulateHallSelectListItem()
        {
            try
            {
                HallLogic   hallLogic = new HallLogic();
                List <HALL> halls     = hallLogic.GetEntitiesBy(p => p.Active);

                if (halls == null || halls.Count <= 0)
                {
                    return(new List <SelectListItem>());
                }

                List <SelectListItem> selectItemList = new List <SelectListItem>();

                SelectListItem list = new SelectListItem();
                list.Value = "";
                list.Text  = Select;
                selectItemList.Add(list);

                foreach (HALL hall in halls)
                {
                    SelectListItem selectList = new SelectListItem();
                    selectList.Value = hall.Id.ToString();
                    selectList.Text  = hall.Name;

                    selectItemList.Add(selectList);
                }

                return(selectItemList);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #3
0
        public HallIntegrationTests()
        {
            var mockMapper = new MapperConfiguration(cfg => cfg.AddProfile(new MappingProfile()));

            _mapper   = mockMapper.CreateMapper();
            hallLogic = new HallLogic(new HallRepository(new DatabaseHall(new DatabaseConnection("Server = mssql.fhict.local; Database = dbi409997; User Id = dbi409997; Password = Ikbencool20042000!;"))), _mapper);
        }
コード例 #4
0
        public HallBasicsTests()
        {
            var mockMapper = new MapperConfiguration(cfg => cfg.AddProfile(new MappingProfile()));

            _mapper   = mockMapper.CreateMapper();
            hallLogic = new HallLogic(new HallContextMock(), _mapper);
        }
コード例 #5
0
        public JsonResult CreateHall(string name, string description)
        {
            JsonResponseModel result = new JsonResponseModel();

            try
            {
                if (!string.IsNullOrEmpty(name))
                {
                    _hallLogic = new HallLogic();
                    HALL existingHall = _hallLogic.GetEntitiesBy(c => c.Name.ToLower().Trim() == name.ToLower().Trim()).LastOrDefault();
                    if (existingHall == null)
                    {
                        HALL maxHall   = _hallLogic.GetAll().LastOrDefault();
                        int  maxHallId = 0;
                        if (maxHall != null)
                        {
                            maxHallId = maxHall.Id + 1;
                        }
                        else
                        {
                            maxHallId = 1;
                        }

                        existingHall = new HALL();

                        existingHall.Id          = maxHallId;
                        existingHall.Name        = name;
                        existingHall.Description = description;
                        existingHall.Active      = true;

                        _hallLogic.Create(existingHall);

                        result.IsError = false;
                        result.Message = "Operation Successful!";
                    }
                    else
                    {
                        result.IsError = true;
                        result.Message = "Hall with the same name exists.";
                    }
                }
                else
                {
                    result.IsError = true;
                    result.Message = "Invalid parameter";
                }
            }
            catch (Exception ex)
            {
                result.IsError = true;
                result.Message = ex.Message;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #6
0
        public ActionResult ManageHall()
        {
            _viewModel = new SetupViewModel();
            _hallLogic = new HallLogic();
            try
            {
                _viewModel.HallList = _hallLogic.GetEntitiesBy(c => c.Active);
            }
            catch (Exception)
            {
                throw;
            }

            return(View(_viewModel));
        }
コード例 #7
0
        public JsonResult SaveHall(int hallId, string name, string description)
        {
            JsonResponseModel result = new JsonResponseModel();

            try
            {
                if (hallId > 0 && !string.IsNullOrEmpty(name))
                {
                    _hallLogic = new HallLogic();
                    HALL hall = _hallLogic.GetEntityBy(c => c.Id == hallId);

                    HALL existingHall = _hallLogic.GetEntitiesBy(c => c.Name.ToLower().Trim() == name.ToLower().Trim() && c.Id != hallId).LastOrDefault();
                    if (existingHall == null)
                    {
                        if (hall != null)
                        {
                            hall.Name        = name;
                            hall.Description = description;

                            _hallLogic.Modify(hall);
                        }

                        result.IsError = false;
                        result.Message = "Operation Successful!";
                    }
                    else
                    {
                        result.IsError = true;
                        result.Message = "Hall with the same name exists.";
                    }
                }
                else
                {
                    result.IsError = true;
                    result.Message = "Invalid parameter";
                }
            }
            catch (Exception ex)
            {
                result.IsError = true;
                result.Message = ex.Message;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #8
0
        public void Should_GetHallsFromTheList_WhenGettingHalls()
        {
            //Arrange
            var       hallLogic = new HallLogic(new HallContextMock(), _mapper);
            HallModel hall      = new HallModel {
                Id = 10, Price = 5, ScreenType = "GetTest", Seats = 30, SeatsTaken = 0
            };

            hallLogic.AddHall(hall);
            bool found = false;

            //Act
            if (hallLogic.GetHalls()[4].Id == 10 && hallLogic.GetHalls()[4].ScreenType == "GetTest")
            {
                found = true;
            }

            //Assert
            Assert.True(found);
        }
コード例 #9
0
        public JsonResult DeleteHall(int hallId)
        {
            JsonResponseModel result = new JsonResponseModel();

            try
            {
                if (hallId > 0)
                {
                    _hallLogic = new HallLogic();
                    EventLogic eventLogic = new EventLogic();
                    EVENT      hallEvent  = eventLogic.GetEntitiesBy(e => e.Hall_Id == hallId).LastOrDefault();

                    if (hallEvent == null)
                    {
                        _hallLogic.Delete(c => c.Id == hallId);

                        result.IsError = false;
                        result.Message = "Operation Successful!";
                    }
                    else
                    {
                        result.IsError = true;
                        result.Message = "Hall is already attached to an event, hence cannot be deleted";
                    }
                }
                else
                {
                    result.IsError = true;
                    result.Message = "Invalid parameter";
                }
            }
            catch (Exception ex)
            {
                result.IsError = true;
                result.Message = ex.Message;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #10
0
ファイル: HallRunTimeInfo.cs プロジェクト: profiles/Fish
 public static void Init(HallLogic login)
 {
     Instance         = new HallRunTimeInfo();
     Instance.m_login = login;
 }
コード例 #11
0
ファイル: HallLogicUI.cs プロジェクト: Pircs/Fishing-1
 public bool Init(ILogic logic, object obj)
 {
     m_Logic = (HallLogic)logic;
     SceneMain.Instance.StartInnerCoroutine(MainInitProcedure(null));
     return(true);
 }