Beispiel #1
0
 /// <summary> - NewSchedule: add new schedule to schedule tbl in db
 public static Schedule_tbl NewSchedule(Schedule_tbl sdal)
 {
     using (projectDBEntities5 db = new projectDBEntities5())
     {
         try
         {
             Schedule_tbl existSchedule = db.Schedule_tbl.Where
                                              (x => x.ScheduleId == sdal.ScheduleId).
                                          Select(x => x).FirstOrDefault();
             if (existSchedule != null)
             {
                 existSchedule.EventCode    = sdal.EventCode;
                 existSchedule.BusinessCode = sdal.BusinessCode;
                 existSchedule.EventDate    = sdal.EventDate;
                 existSchedule.Duration     = sdal.Duration;
                 existSchedule.Done         = sdal.Done;
                 existSchedule.Cost         = sdal.Cost;
                 existSchedule.Hour         = sdal.Hour;
                 existSchedule.Description  = sdal.Description;
                 existSchedule.Subject      = sdal.Subject;
                 db.SaveChanges();
                 return(existSchedule);
             }
             else
             {
                 try
                 {
                     Schedule_tbl newSchedule = new Schedule_tbl
                     {
                         EventCode    = sdal.EventCode,
                         BusinessCode = sdal.BusinessCode,
                         EventDate    = sdal.EventDate,
                         Duration     = sdal.Duration,
                         Done         = sdal.Done,
                         Cost         = sdal.Cost,
                         Hour         = sdal.Hour,
                         Description  = sdal.Description,
                         Subject      = sdal.Subject,
                         ScheduleId   = sdal.ScheduleId
                     };
                     db.Schedule_tbl.Add(newSchedule);
                     db.SaveChanges();
                     return(newSchedule);
                 }
                 catch (Exception e)
                 {
                     Console.WriteLine(e);
                     return(null);
                 }
             }
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
             return(null);
         }
     }
 }
 /// <summary> NewHours- the owner add the opening hours of his business to db
 public static List <BusinessOpeningHours_tbl> NewHours(List <BusinessOpeningHours_tbl> hdal)
 {
     foreach (var h in hdal)
     {
         try
         {
             using (projectDBEntities5 db = new projectDBEntities5())
             {
                 BusinessOpeningHours_tbl newHour = new BusinessOpeningHours_tbl
                 {
                     BusinessCode = h.BusinessCode,
                     StartHour    = h.StartHour,
                     EndHour      = h.EndHour,
                     DayInWeek    = h.DayInWeek,
                 };
                 db.BusinessOpeningHours_tbl.Add(newHour);
                 db.SaveChanges();
             }
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
             return(null);
         }
     }
     return(hdal);
 }
Beispiel #3
0
 /// <summary> - NewUser: add new user to user tbl in db.
 public static Users__tbl NewUser(Users__tbl udal)
 {
     try
     {
         using (projectDBEntities5 db = new projectDBEntities5())
         {
             Users__tbl newUser = new Users__tbl
             {
                 UserName     = udal.UserName,
                 UserLastName = udal.UserLastName,
                 UserMail     = udal.UserMail,
                 UserPassword = udal.UserPassword,
                 UserType     = udal.UserType
             };
             db.Users__tbl.Add(newUser);
             db.SaveChanges();
             return(newUser);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(null);
     }
 }
Beispiel #4
0
 /// <summary> - NewBusiness: add business to business tbl in db.
 public static Business__tbl NewBusiness(Business__tbl budal)
 {
     try
     {
         using (projectDBEntities5 db = new projectDBEntities5())
         {
             Business__tbl newBusiness = new Business__tbl
             {
                 BusinessCode        = budal.BusinessCode,
                 CategoryCode        = budal.CategoryCode,
                 BusinessOwnerCode   = budal.BusinessOwnerCode,
                 BusinessName        = budal.BusinessName,
                 FullAddress         = budal.FullAddress,
                 Phone               = budal.Phone,
                 BusinessDescription = budal.BusinessDescription,
             };
             db.Business__tbl.Add(newBusiness);
             //db.Entry(newUser).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             return(newBusiness);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(null);
     }
 }
Beispiel #5
0
 public static int RemoveSchedule(string id)
 {
     try
     {
         using (projectDBEntities5 db = new projectDBEntities5())
         {
             Schedule_tbl row   = db.Schedule_tbl.Where(x => x.ScheduleId == id).Select(x => x).FirstOrDefault();
             Schedule_tbl count = db.Schedule_tbl.Remove(row);
             db.SaveChanges();
             return(1);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(0);
     }
 }
Beispiel #6
0
 /// <summary> - NewEvent: add new event in events tbl in db when user is register
 public static Events__tbl NewEvent(Events__tbl edal)
 {
     try
     {
         using (projectDBEntities5 db = new projectDBEntities5())
         {
             Events__tbl newEvent = new Events__tbl
             {
                 EventCode    = edal.EventCode,
                 UserCode     = edal.UserCode,
                 EventDate    = edal.EventDate,
                 GroomOrBride = edal.GroomOrBride
             };
             db.Events__tbl.Add(newEvent);
             db.SaveChanges();
             return(newEvent);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(null);
     }
 }