Example #1
0
        public IHttpActionResult Postscheduler(scheduler scheduler)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.scheduler.Add(scheduler);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (schedulerExists(scheduler.id_schedule))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = scheduler.id_schedule }, scheduler));
        }
Example #2
0
    protected void updateDetails_Click(object sender, EventArgs e)
    {
        try
        {
            scheduler schedulerObj = new scheduler();

            string newSday      = sday.SelectedValue;
            string newEday      = eday.SelectedValue;
            string newStime     = stime.Text;
            string newEtime     = etime.Text;
            string newInWindow  = signinWindow.Text;
            string newOutWindow = signOutWindow.Text;
            if (sday.SelectedIndex <= eday.SelectedIndex)
            {
                schedulerObj.modifyDutyRequestRules(newSday, newEday, newStime, newEtime, newInWindow, newOutWindow);

                Response.Redirect(Request.RawUrl);
                msg.Text = "Details has been updated, thank you.";
            }
            else
            {
                msg.Text = "Start day must be before the end day!";
            }
        }
        catch (Exception ex)
        {
            msg.Text = "There was something wrong, error + " + ex.Message;
        }
    }
Example #3
0
    protected void assignDutyToShift_btn_Click(object sender, EventArgs e)
    {
        if ((dayList.SelectedIndex != 0 && locationDropList.SelectedIndex != 0) && shiftNameDropList.SelectedIndex != 0)
        {
            string[] details = new string[5];
            details[0] = DutyDropList.SelectedValue;
            details[1] = shiftNameDropList.SelectedValue;
            details[2] = locationDropList.SelectedValue;
            details[3] = dayList.SelectedValue;
            details[4] = "1";

            try
            {
                scheduler schedulerObject = new scheduler();
                schedulerObject.assignDutyToShift(details);
                Response.Redirect(Request.RawUrl);
            }
            catch (Exception ex)
            {
                msg.Text = "The duty was not assigned, as this details exist for another duty in the system.";
            }
        }
        else
        {
            msg.Text = "Duty is not assigned because not all required details are specified";
        }
    }
Example #4
0
        public IHttpActionResult Putscheduler(int id, scheduler scheduler)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != scheduler.id_schedule)
            {
                return(BadRequest());
            }

            db.Entry(scheduler).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!schedulerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #5
0
        public IHttpActionResult Getscheduler(int id)
        {
            scheduler scheduler = db.scheduler.Find(id);

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

            return(Ok(scheduler));
        }
Example #6
0
    protected void add_btn_Click(object sender, EventArgs e)
    {
        scheduler schedulerObj = new scheduler();

        object[] TA_information = new object[17];

        string TA_name          = name.Text;
        string tp               = tp_number.Text;
        string ta_code          = ta_number.Text;
        string pemail           = privateEmail.Text;
        string TA_Email         = taEmail.Text;
        string TA_contactNumber = contact_number.Text;
        string password         = "******";
        string TA_dob           = dob.Text;
        char   TA_gender        = char.Parse(gender.SelectedValue.ToString());
        string TA_nationality   = nationality.SelectedValue.ToString();
        string TA_address       = address.Text;
        string TA_intake        = intake.Text;
        double TA_gpa           = double.Parse(gpa.Text);
        string TA_achievements  = achievements.Text;
        string sdate            = selection_date.Text;
        int    warning          = int.Parse(warningLetter.Text);
        int    positionID       = 2;

        TA_information[0]  = TA_name;
        TA_information[1]  = tp;
        TA_information[2]  = ta_code;
        TA_information[3]  = pemail;
        TA_information[4]  = TA_Email;
        TA_information[5]  = TA_contactNumber;
        TA_information[6]  = password;
        TA_information[7]  = TA_dob;
        TA_information[8]  = TA_gender;
        TA_information[9]  = TA_nationality;
        TA_information[10] = TA_address;
        TA_information[11] = TA_intake;
        TA_information[12] = TA_gpa;
        TA_information[13] = TA_achievements;
        TA_information[14] = sdate;
        TA_information[15] = warning;
        TA_information[16] = positionID;

        try
        {
            schedulerObj.addNewTA(TA_information);
            msg.Text = "TA has been added successfully.";
            emptyForm();
        }
        catch (Exception ex)
        {
            msg.Text = "TA was not added, error: " + ex.Message;
        }
    }
Example #7
0
        public IHttpActionResult Deletescheduler(int id)
        {
            scheduler scheduler = db.scheduler.Find(id);

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

            db.scheduler.Remove(scheduler);
            db.SaveChanges();

            return(Ok(scheduler));
        }
Example #8
0
        public void TestMethod1()
        {
            //Arrange
            var startday = 2;
            var endday   = 4;
            var result   = 0;

            var check         = startday + endday;
            var schedulertest = new scheduler();

            //Act
            result = schedulertest.adder(startday, endday);
            //Assert
            Assert.Equals(result, check);
        }
Example #9
0
    protected void delete_duty_Click(object sender, EventArgs e)
    {
        int       dutyID        = Int32.Parse(duties.SelectedValue);
        scheduler scheduler_obj = new scheduler();

        try
        {
            scheduler_obj.deleteDuty(dutyID);
            Response.Redirect(Request.RawUrl);
        }
        catch (Exception ex)
        {
            duty_msg.Text = "Duty could not be deleted, please delete the associated recoreds before deleting it.";
        }
    }
Example #10
0
    protected void delete_shift_Click(object sender, EventArgs e)
    {
        int       shiftID       = Int32.Parse(shifts.SelectedValue);
        scheduler scheduler_obj = new scheduler();

        try
        {
            scheduler_obj.deleteShift(shiftID);
            Response.Redirect(Request.RawUrl);
        }
        catch (Exception ex)
        {
            shift_msg.Text = "Shift could not be deleted, please delete all the associated duities this shift before deleting it ";
        }
    }
Example #11
0
    /* DELETE actions */
    protected void delete_location_Click(object sender, EventArgs e)
    {
        int       locationID    = Int32.Parse(locations.SelectedValue);
        scheduler scheduler_obj = new scheduler();

        try
        {
            scheduler_obj.deleteLocation(locationID);
            Response.Redirect(Request.RawUrl);
        }
        catch (Exception ex)
        {
            location_msg.Text = "Location could not be deleted, please delete all the associated shifts and duties with this location before deleting it";
        }
    }
    protected void assignShitToLocation_btn_Click(object sender, EventArgs e)
    {
        if ((locationDropList.SelectedIndex != 0 && shiftNameDropList.SelectedIndex != 0) && dayDropList.SelectedIndex != 0)
        {
            if (isStartTimeBeforeEndTime(startTime.Text, endTime.Text) == true)
            {
                if (isThereTimeInterference(int.Parse(locationDropList.SelectedValue), dayDropList.SelectedValue, startTime.Text) != true)
                {
                    string[] details = new string[5];
                    details[0] = shiftNameDropList.SelectedValue;
                    details[1] = locationDropList.SelectedValue;
                    details[2] = startTime.Text;
                    details[3] = endTime.Text;
                    details[4] = dayDropList.SelectedValue;

                    try
                    {
                        scheduler schedulerObject = new scheduler();
                        schedulerObject.assignShiftToLocation(details);
                        Response.Redirect(Request.RawUrl);
                    }
                    catch (MySql.Data.MySqlClient.MySqlException ex)
                    {
                        msg.Text = "This shift is already added to the chosen location, please either modify or remove it before performing this action!." + ex.Message;
                    }
                    catch (Exception ex1)
                    {
                        msg.Text = "There was something wrong, error: " + ex1.Message;
                    }
                }
                else
                {
                    msg.Text = "The shift cannot be added because the timing interfers with another shift at the same location.";
                }
            }
            else
            {
                msg.Text = "Start time must be before end time!";
            }
        }
        else
        {
            msg.Text = "Shift was not assigned, please specify all the required details!.";
        }
    }
Example #13
0
        public IHttpActionResult PostPricePitch(scheduler scheduler)
        {
            if (scheduler == null)
            {
                return(BadRequest());
            }

            if (scheduler.hour.Hours == 0 || scheduler.id_pitch == 0 || scheduler.date_insert.Year == 1)
            {
                return(BadRequest());
            }

            IQueryable <object> getPrice  = null;
            DateTime            dateEntry = scheduler.date_insert.Date;

            holidays holiday = (from a in db.holidays
                                where a.date == dateEntry
                                select a).FirstOrDefault();

            if (holiday != null)
            {
                getPrice = (from a in db.scheduler
                            where a.id_day == 8 &&
                            a.id_pitch == scheduler.id_pitch &&
                            a.hour.Hours == scheduler.hour.Hours
                            select new { id_pitch = a.id_pitch, value = a.value });
            }
            else
            {
                int intDayOfWeek = scheduler.date_insert.DayOfWeek.GetHashCode();
                if (intDayOfWeek == 0)
                {
                    intDayOfWeek = 7;
                }

                getPrice = (from a in db.scheduler
                            where a.id_day == intDayOfWeek &&
                            a.id_pitch == scheduler.id_pitch &&
                            a.hour.Hours == scheduler.hour.Hours
                            select new { id_pitch = a.id_pitch, value = a.value });
            }

            return(Ok(getPrice));
        }
Example #14
0
    /* Save details wether they are new details or modification for existing record */
    protected void save_location_btn_Click(object sender, EventArgs e)
    {
        string name    = location_name.Text.Trim();
        string address = location_address.Text.Trim();

        scheduler scheduler_obj = new scheduler();

        //to add values if no editing is taking place.
        if (cancel_location_btn.Visible == false)
        {
            try
            {
                if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(address))
                {
                    location_msg.Text = "Please fill in the full details.";
                }
                else
                {
                    scheduler_obj.addLocation(name, address);
                    Response.Redirect(Request.RawUrl);
                }
            }
            catch (Exception ex)
            {
                location_msg.Text = "Location could not be added, error: " + ex.Message;
            }
        }
        else  //to save values if editing is taking place.
        {
            try
            {
                int locationID = Int32.Parse(locations.SelectedValue);
                scheduler_obj.modifyLocation(locationID, name, address);
                Response.Redirect(Request.RawUrl);
            }
            catch (Exception ex)
            {
                location_msg.Text = "Location could not be modified, error: " + ex.Message;
            }
        }
    }
Example #15
0
    protected void save_duty_btn_Click(object sender, EventArgs e)
    {
        string title       = duty_title.Text.Trim();
        string description = duty_desc.Text.Trim();

        scheduler scheduler_obj = new scheduler();

        if (cancel_duty_btn.Visible == false)
        {
            try
            {
                if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(description))
                {
                    duty_msg.Text = "Please specify the duty's full details.";
                }
                else
                {
                    scheduler_obj.addDuty(title, description);
                    Response.Redirect(Request.RawUrl);
                }
            }
            catch (Exception ex)
            {
                duty_msg.Text = "Duty could not be added, error: " + ex.Message;
            }
        }
        else
        {
            try
            {
                int dutyID = Int32.Parse(duties.SelectedValue);
                scheduler_obj.modifyDuty(dutyID, title, description);
                Response.Redirect(Request.RawUrl);
            }
            catch (Exception ex)
            {
                duty_msg.Text = "Duty could not be modified, error: " + ex.Message;
            }
        }
    }
Example #16
0
    protected void save_shift_btn_Click(object sender, EventArgs e)
    {
        string name = shift_name.Text.Trim();

        scheduler scheduler_obj = new scheduler();

        if (cancel_shift_btn.Visible == false)
        {
            try
            {
                if (string.IsNullOrEmpty(name))
                {
                    shift_msg.Text = "Please specify the shift name.";
                }
                else
                {
                    scheduler_obj.addShift(name);
                    Response.Redirect(Request.RawUrl);
                }
            }
            catch (Exception ex)
            {
                shift_msg.Text = "Shift could not be added, error: " + ex.Message;
            }
        }
        else
        {
            try
            {
                int shiftID = int.Parse(shifts.SelectedValue);
                scheduler_obj.modifyShift(shiftID, name);
                Response.Redirect(Request.RawUrl);
            }
            catch (Exception ex)
            {
                shift_msg.Text = "Shift could not be modified, error: " + ex.Message;
            }
        }
    }
Example #17
0
 ReferenceEquals(scheduler, PipeScheduler.Inline) ? null : scheduler;
Example #18
0
 private IScheduler ToScheduler(scheduler scheduler)
 {
     return(new Scheduler(scheduler.schId, scheduler.schName, scheduler.schDescr, scheduler.schTimeFrom, scheduler.schTimeTo, scheduler.hallId, scheduler.showId));
 }