Ejemplo n.º 1
0
        public static bool updateSubsciber(SubsciberDTO a)
        {
            using (libraryEntities db = new libraryEntities())
            {
                Subscriber au = db.Subscribers.First(x => x.id == a.id);
                au.firstName = a.firstName;
                au.lastName  = a.lastName;
                au.id        = a.id;
                au.isDeleted = a.isDeleted;
                au.address   = a.address;
                au.phon      = a.phon;
                au.startDate = a.startDate;
                au.type      = a.type;
                au.email     = a.email;


                try
                {
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
Ejemplo n.º 2
0
 public static Subscriber ConvertSubscriberDTOToDAL(SubsciberDTO subscriber)
 {
     return(new Subscriber
     {
         id = subscriber.id,
         firstName = subscriber.firstName,
         lastName = subscriber.lastName,
         address = subscriber.address,
         phon = subscriber.phon,
         startDate = subscriber.startDate,
         type = subscriber.type,
         isDeleted = subscriber.isDeleted,
         email = subscriber.email
     });
 }
Ejemplo n.º 3
0
 public static bool addSubscriber(SubsciberDTO s)
 {
     using (libraryEntities db = new libraryEntities())
     {
         if (db.Subscribers.FirstOrDefault(x => x.id == s.id) != null)
         {
             s.startDate = DateTime.Today;
             updateSubsciber(s);
         }
         else
         {
             db.Subscribers.Add(Converters.SubsriberConverter.ConvertSubscriberDTOToDAL(s));
         }
         try
         {
             db.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Ejemplo n.º 4
0
 public IHttpActionResult UpdateSubscriber(SubsciberDTO sub)
 {
     return(Ok(BL.subscriberBL.updateSubsciber(sub)));
 }
Ejemplo n.º 5
0
 public IHttpActionResult AddAddSubscriberBook(SubsciberDTO sub)
 {
     return(Ok(BL.subscriberBL.addSubscriber(sub)));
 }