예제 #1
0
        public Timeslot GetTimeSlot(string timeslotCode)
        {
            Timeslot timeslot = new Timeslot();

            timeslot = null;
            try {
                using (var DCEnt = new DCFIEntities())
                {
                    timeslot = (from t in DCEnt.Timeslots
                                where t.TimeSlotCode == timeslotCode
                                select t).FirstOrDefault();
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(timeslot);
        }
예제 #2
0
        public Timeslot GetTimeSlot(string timeslotCode)
        {
            Timeslot timeslot = new Timeslot();
            timeslot = null;
            try { 
            using (var DCEnt = new DCFIEntities())
            {
                timeslot = (from t in DCEnt.Timeslots
                        where t.TimeSlotCode == timeslotCode
                        select t).FirstOrDefault();

            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
                }
            }
            return timeslot;

        }
예제 #3
0
 private void ConvertTimeslotToTimeslotBDO(Timeslot timeslot, TimeslotBDO tBDO)
 {
     tBDO.TimeSlotCode = timeslot.TimeSlotCode;
     tBDO.TimeStart    = timeslot.TimeStart;
     tBDO.TimeEnd      = timeslot.TimeEnd;
     tBDO.Days         = timeslot.Days;
     tBDO.Deactivated  = timeslot.Deactivated;
 }
예제 #4
0
 public void ConvertTimeslotToTimeslotBDO(Timeslot timeslot, TimeslotBDO tBDO)
 {
     tBDO.TimeSlotCode = timeslot.TimeSlotCode;
     tBDO.TimeStart = timeslot.TimeStart;
     tBDO.TimeEnd = timeslot.TimeEnd;
     tBDO.Days = timeslot.Days;
     tBDO.Deactivated = timeslot.Deactivated;
     tBDO.TotalMins = timeslot.TotalMins;
 }
예제 #5
0
        public Timeslot GetTimeSlot(string timeslotCode)
        {
            Timeslot timeslot = new Timeslot();

            timeslot = null;

            using (var DCEnt = new DCFIEntities())
            {
                timeslot = (from t in DCEnt.Timeslots
                            where t.TimeSlotCode == timeslotCode
                            select t).FirstOrDefault();
            }

            return(timeslot);
        }
예제 #6
0
        public Boolean UpdateTimeslot(ref TimeslotBDO tBDO, ref string message)
        {
            message = "Timeslot updated successfully.";
            Boolean ret = true;

            try {
                using (var DCEnt = new DCFIEntities())
                {
                    var      timeslotCode = tBDO.TimeSlotCode;
                    Timeslot timeslotInDB = (from t in DCEnt.Timeslots
                                             where t.TimeSlotCode == timeslotCode
                                             select t).FirstOrDefault();
                    if (timeslotInDB == null)
                    {
                        throw new Exception("No timeslot with code " + tBDO.TimeSlotCode);
                    }
                    DCEnt.Timeslots.Remove(timeslotInDB);

                    timeslotInDB.TimeStart = tBDO.TimeStart;
                    timeslotInDB.TimeEnd   = tBDO.TimeEnd;
                    timeslotInDB.Days      = tBDO.Days;
                    timeslotInDB.TotalMins = tBDO.TotalMins;

                    DCEnt.Timeslots.Attach(timeslotInDB);
                    DCEnt.Entry(timeslotInDB).State = System.Data.Entity.EntityState.Modified;
                    int num = DCEnt.SaveChanges();

                    if (num != 1)
                    {
                        ret     = false;
                        message = "No timeslot is updated.";
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(ret);
        }
예제 #7
0
        public Timeslot GetTimeSlot(string timeslotCode)
        {
            Timeslot timeslot = new Timeslot();
            timeslot = null;

            using (var DCEnt = new DCFIEntities())
            {
                timeslot = (from t in DCEnt.Timeslots
                        where t.TimeSlotCode == timeslotCode
                        select t).FirstOrDefault();

            }

            return timeslot;

        }
예제 #8
0
        public Boolean CreateTimeslot(ref TimeslotBDO tBDO, ref string message)
        {
            message = "Timeslot Added Successfully";
            bool ret = true;

            Timeslot t = new Timeslot()
            {
                TimeSlotCode = tBDO.TimeSlotCode,
                TimeStart    = tBDO.TimeStart,
                TimeEnd      = tBDO.TimeEnd,
                Days         = tBDO.Days,
                TotalMins    = tBDO.TotalMins
            };

            try {
                using (var DCEnt = new DCFIEntities())
                {
                    DCEnt.Timeslots.Attach(t);
                    DCEnt.Entry(t).State = System.Data.Entity.EntityState.Added;
                    int num = DCEnt.SaveChanges();
                    tBDO.TimeSlotCode = t.TimeSlotCode;

                    if (num != 1)
                    {
                        ret     = false;
                        message = "Adding of Timeslot failed";
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(ret);
        }
예제 #9
0
        public Boolean CreateTimeslot(ref TimeslotBDO tBDO, ref string message)
        {
            message = "Timeslot Added Successfully";
            bool ret = true;

            Timeslot t = new Timeslot()
            {
                TimeSlotCode = tBDO.TimeSlotCode,
                TimeStart = tBDO.TimeStart,
                TimeEnd = tBDO.TimeEnd,
                Days = tBDO.Days,
                TotalMins=tBDO.TotalMins
            };
            try {
                using (var DCEnt = new DCFIEntities())
            {
                DCEnt.Timeslots.Attach(t);
                DCEnt.Entry(t).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();
                tBDO.TimeSlotCode = t.TimeSlotCode;

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of Timeslot failed";
                }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
                }
            }
            return ret;
        }
예제 #10
0
        public Boolean DeleteTimeslot(string timeslotCode, ref string message)
        {
            message = "Timeslot Deleted successfully.";
            Boolean ret = true;

            try {
                using (var DCEnt = new DCFIEntities())
                {
                    Timeslot tInDB = (from t in DCEnt.Timeslots
                                      where t.TimeSlotCode == timeslotCode
                                      select t).FirstOrDefault();

                    if (tInDB == null)
                    {
                        throw new Exception("No timeslot with code " + tInDB);
                    }

                    DCEnt.Timeslots.Remove(tInDB);
                    DCEnt.Entry(tInDB).State = System.Data.Entity.EntityState.Deleted;
                    int num = DCEnt.SaveChanges();
                    if (num != 1)
                    {
                        ret     = false;
                        message = "Deletion of Timeslot Failed.";
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(ret);
        }
예제 #11
0
        public TimeslotBDO GetTimeslotBDO(string timeslotCode)
        {
            TimeslotBDO timeslotBDO = null;

            try {
                using (var DCEnt = new DCFIEntities())
                {
                    Timeslot timeslot = new Timeslot();
                    timeslot = (from t in DCEnt.Timeslots
                                where t.TimeSlotCode == timeslotCode
                                select t).FirstOrDefault();

                    if (timeslot != null)
                    {
                        timeslotBDO = new TimeslotBDO()
                        {
                            TimeSlotCode = timeslot.TimeSlotCode,
                            TimeStart    = timeslot.TimeStart,
                            TimeEnd      = timeslot.TimeEnd,
                            Days         = timeslot.Days,
                            Deactivated  = timeslot.Deactivated,
                            TotalMins    = timeslot.TotalMins
                        };
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }
            }
            return(timeslotBDO);
        }
예제 #12
0
        public TimeslotBDO GetTimeslotBDO(string timeslotCode)
        {
            TimeslotBDO timeslotBDO = null;
            try { 
            using (var DCEnt = new DCFIEntities())
            {
                Timeslot timeslot = new Timeslot();
                    timeslot = (from t in DCEnt.Timeslots
                             where t.TimeSlotCode == timeslotCode
                              select t).FirstOrDefault();

                if (timeslot != null)
                {
                        timeslotBDO = new TimeslotBDO()
                        {
                            TimeSlotCode = timeslot.TimeSlotCode,
                            TimeStart = timeslot.TimeStart,
                            TimeEnd = timeslot.TimeEnd,
                            Days = timeslot.Days,
                            Deactivated = timeslot.Deactivated,
                            TotalMins = timeslot.TotalMins
                    };
                }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
                }
            }
            return timeslotBDO;
        }
예제 #13
0
        public TimeslotBDO GetTimeslotBDO(string timeslotCode)
        {
            TimeslotBDO timeslotBDO = null;
            using (var DCEnt = new DCFIEntities())
            {
                Timeslot timeslot = new Timeslot();
                    timeslot = (from t in DCEnt.Timeslots
                             where t.TimeSlotCode == timeslotCode
                             select t).FirstOrDefault();

                if (timeslot != null)
                {
                    timeslotBDO = new TimeslotBDO()
                    {
                        TimeSlotCode = timeslot.TimeSlotCode,
                        TimeStart = timeslot.TimeStart,
                        TimeEnd = timeslot.TimeEnd,
                        Days = timeslot.Days,
                        Deactivated = timeslot.Deactivated
                    };
                }
            }
            return timeslotBDO;
        }
예제 #14
0
        public Boolean CreateTimeslot(ref TimeslotBDO tBDO, ref string message)
        {
            message = "Timeslot Added Successfully";
            bool ret = true;

            Timeslot t = new Timeslot()
            {
                TimeSlotCode = tBDO.TimeSlotCode,
                TimeStart = tBDO.TimeStart,
                TimeEnd = tBDO.TimeEnd,
                Days = tBDO.Days
            };

            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.Timeslots.Attach(t);
                DCEnt.Entry(t).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();
                tBDO.TimeSlotCode = t.TimeSlotCode;

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of Timeslot failed";
                }
            }
            return ret;
        }