Ejemplo n.º 1
0
        /// <summary>
        /// Updates the timesheet with new information.
        /// </summary>
        /// <param name="ts">TimeSheet object with new values.</param>
        public static ReturnStatus EditTimeSheet(TimeSheet ts)
        {
            ReturnStatus st = new ReturnStatus();

            st.data = null;
            try
            {
                VolunteerDbContext db = new VolunteerDbContext();
                db.Entry(ts).State = EntityState.Modified;
                db.SaveChanges();

                st.errorCode = ReturnStatus.ALL_CLEAR;
                return(st);
            }
            catch (Exception e)
            {
                st.errorCode    = ReturnStatus.COULD_NOT_CONNECT_TO_DATABASE;
                st.errorMessage = e.ToString();
                return(st);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deletes the TimeSheet from the database.
        /// </summary>
        /// <param name="ts">TimeSheet object to be deleted.</param>
        public static ReturnStatus DeleteTimeSheet(TimeSheet ts)
        {
            ReturnStatus st = new ReturnStatus();

            st.data = null;
            try
            {
                VolunteerDbContext db = new VolunteerDbContext();
                db.timeSheets.Attach(ts);
                db.timeSheets.Remove(ts);
                db.SaveChanges();

                st.errorCode = ReturnStatus.ALL_CLEAR;
                return(st);
            }
            catch (Exception e)
            {
                st.errorCode    = (int)ReturnStatus.COULD_NOT_CONNECT_TO_DATABASE;
                st.errorMessage = e.ToString();
                return(st);
            }
        }