Exemple #1
0
    // Get All Occupation By ID
    public OccupationModel GetOccupationById(int id)
    {
        // Declare list to work with
        OccupationModel occupation = new OccupationModel();

        // Establish database connection
        SqlConnection con = new SqlConnection(connectionString);

        con.Open();

        // sql command get occupation by provided id
        SqlCommand cmd = new SqlCommand("select * from Occupation where OccupationId = " + id, con);

        // This read database command
        SqlDataReader reader = cmd.ExecuteReader();

        if (reader.Read() == true)
        {
            occupation.OccupationId = reader.GetInt32(0);
            occupation.Description  = reader.GetString(1);
        }

        // Close current connection to the database
        con.Close();

        return(occupation);
    }
Exemple #2
0
    // Get All Occupations
    public List <OccupationModel> GetAllOccupations()
    {
        // Declare list to work with
        List <OccupationModel> occupationsList = new List <OccupationModel>();

        // Establish database connection
        SqlConnection con = new SqlConnection(connectionString);

        con.Open();

        // sql command for Occupation
        SqlCommand cmd = new SqlCommand("select * from Occupation order by Description", con);

        // This read database command
        SqlDataReader reader = cmd.ExecuteReader();

        while (reader.Read())
        {
            // create new occupation instance
            OccupationModel occupations = new OccupationModel
            {
                OccupationId = reader.GetInt32(0),
                Description  = reader.GetString(1)
            };

            // add all occupation to the list
            occupationsList.Add(occupations);
        }

        // Close current connection to the database
        con.Close();

        return(occupationsList);
    }
        public ActionResult CreateOccupation(OccupationModel ObjOccupation)
        {
            var resultDto = new ResultDto();

            if (ModelState.IsValid)
            {
                var occupationDto = Mapper.Map <OccupationModel, OccupationDto>(ObjOccupation);
                occupationDto.UserId = UserInfo.UserID;
                if (occupationDto.OccupationID == 0)
                {
                    resultDto = _OccupationService.Insert(occupationDto);
                }
                else
                {
                    resultDto = _OccupationService.Update(occupationDto);
                }

                if (resultDto.ObjectId > 0)
                {
                    occupationDto        = _OccupationService.GetByID(resultDto.ObjectId);
                    ObjOccupation        = Mapper.Map <OccupationDto, OccupationModel>(occupationDto);
                    resultDto.ObjectCode = occupationDto.OccupationCode;
                }
            }

            SelectList occupationCategory = GetDropDownListByMasterCode(Enums.RefMasterCodes.OCCUPATION_TYPE);

            ViewBag.OccupationCategory = occupationCategory;

            ViewBag.Result = resultDto;
            return(View(ObjOccupation));
        }
        public ActionResult OccupationView(int iets = 0)
        {
            string   dateInput = Request.Form["date1"];
            DateTime beginDate = new DateTime(00 - 00 - 0000);
            DateTime endDate   = new DateTime(00 - 00 - 0000);

            if (dateInput.Equals("") == false)
            {
                beginDate = DateTime.ParseExact(dateInput, "yyyy/MM/dd", provider);
            }

            string dateInput2 = Request.Form["date2"];

            if (dateInput2.Equals("") == false)
            {
                endDate = DateTime.ParseExact(dateInput2, "yyyy/MM/dd", provider);
            }

            OccupationModel model = new OccupationModel();

            model.movies     = ChairRepo.Chairs.Where(c => c.ScheduleID.Date >= beginDate && c.ScheduleID.Date <= endDate && c.Reservation == 2).OrderBy(c => c.ScheduleID.movie.Name).GroupBy(c => c.ScheduleID.movie.Name).Select(c => c.Key).ToList();
            model.countMovie = ChairRepo.Chairs.Where(c => c.ScheduleID.Date >= beginDate && c.ScheduleID.Date <= endDate && c.Reservation == 2).OrderBy(c => c.ScheduleID.movie.Name).GroupBy(c => c.ScheduleID.movie.Name).Select(c => c.Count()).ToList();

            model.halls     = ChairRepo.Chairs.Where(c => c.ScheduleID.Date >= beginDate && c.ScheduleID.Date <= endDate && c.Reservation == 2).OrderBy(c => c.ScheduleID.hall.Name).GroupBy(c => c.ScheduleID.hall.Name).Select(c => c.Key).ToList();
            model.countHall = ChairRepo.Chairs.Where(c => c.ScheduleID.Date >= beginDate && c.ScheduleID.Date <= endDate && c.Reservation == 2).OrderBy(c => c.ScheduleID.hall.Name).GroupBy(c => c.ScheduleID.hall.Name).Select(c => c.Count()).ToList();
            return(View("OccupationResults", model));
        }
        public ActionResult CreateOccupation(string ID)
        {
            //SelectList occupationCategory = GetDropDownListByMasterCode(Enums.RefMasterCodes.OCCUPATION_TYPE);



            int occupationId = string.IsNullOrEmpty(ID.DecryptString()) ? default(int) : Convert.ToInt32(ID.DecryptString());

            SelectList occupationCategory = GetDropDownListByMasterCode(Enums.RefMasterCodes.OCCUPATION_TYPE);

            ViewBag.OccupationCategory = occupationCategory;


            OccupationDto occupationDto = new OccupationDto();

            if (occupationId > 0)
            {
                occupationDto = _OccupationService.GetByID(occupationId);
            }
            OccupationModel occupationmodel = Mapper.Map <OccupationDto, OccupationModel>(occupationDto);

            ViewBag.Result = new ResultDto();
            return(View(occupationmodel));
            //OccupationModel occupationModel = new OccupationModel();
            //if (ID.HasValue)
            //{
            //    occupationDto = _OccupationService.GetByID(ID.Value);
            //    occupationModel = Mapper.Map<OccupationDto, OccupationModel>(occupationDto);
            //  //}
            //  if (occupationId>0)
            //      occupationDto= _OccupationService.GetByID(occupationId);


            //  ViewBag.Result = new ResultDto();

            ////  SelectList occupationCategory = GetDropDownListByMasterCode(Enums.RefMasterCodes.OCCUPATION_TYPE);
            //  ViewBag.OccupationCategory = occupationCategory;
            //  return View(occupationmodel);
        }
Exemple #6
0
 public OccupationViewModel(OccupationModel model)
 {
     this.model = model;
     this.model.PropertyChanged += new PropertyChangedEventHandler(model_PropertyChanged);
 }