public string DeleteMember(int id) {

            string rpta;
            Memberships_levels member = new Memberships_levels();
            try {
                using (var ctx = new transshipEntities()) {
                    member = ctx.Memberships_levels.FirstOrDefault(x => x.membershipId == id);

                    if (member != null) {

                        ctx.Entry(member).State = EntityState.Deleted;
                        ctx.SaveChanges();

                        rpta = "ok";

                    } else {
                        rpta = "fail";
                    }

                }
            } catch (Exception e) {
                LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty));
                throw e;
            }

            return rpta;
        }
Beispiel #2
0
        public HttpResponseMessage Put(Memberships_levels model)
        {
            try {
                BOMemberShip_Levels member = new BOMemberShip_Levels();
                Memberships_levels  memb;

                memb = member.UpdateMemberShip(model);
                return(Request.CreateResponse(HttpStatusCode.OK, memb));
            } catch (Exception e) {
                ErrorMessage mensaje = new ErrorMessage("2.1", "Exception to update memberShip levels - " + e.GetBaseException().Message, e.ToString());
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, mensaje));
            }
        }
        public Memberships_levels SaveMemberShip(Memberships_levels model) {

            var member = new Memberships_levels();
            try {
                using (var ctx = new transshipEntities()) {
                    member = ctx.Memberships_levels.Add(model);
                    ctx.SaveChanges();

                    return member;
                }
            } catch (Exception e) {
                LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty));
                throw e;
            }
        }
        public Memberships_levels UpdateMember(Memberships_levels model) {
            Memberships_levels member = new Memberships_levels();

            member = model;
            try {
                using (var ctx = new transshipEntities()) {
                    ctx.Entry(member).State = EntityState.Modified;

                    ctx.SaveChanges();

                    return member;
                }
            } catch (Exception e) {
                LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty));
                throw e;
            }
        }
Beispiel #5
0
        public Payments getUser(string email)
        {
            var                user = new Payments();
            Payments           p;
            Memberships_levels m = new Memberships_levels();

            try {
                using (var ctx = new transshipEntities()) {
                    //ctx.Configuration.LazyLoadingEnabled = false;
                    //list = ctx.Memberships_levels.Include("customers").ToList();

                    var query = (from us in ctx.users
                                 join cs in ctx.customers on us.customerId equals cs.customerId
                                 join os in ctx.countries on cs.countryId equals os.CountryID
                                 where us.email == email
                                 select new {
                        status = cs.status,
                        company_name = cs.company_name,
                        customerId = cs.customerId,
                        address1 = cs.address1,
                        address2 = cs.address2,
                        state = cs.state,
                        city = cs.city,
                        Country = os.CountryName,
                        countryId = os.CountryID,
                        expired = cs.expiration_date,
                        contactName = us.full_name,
                        zipcod = cs.zipcode,
                        userId = us.userId,
                        role = us.role,
                        UserType = us.user_type,
                        email = us.email,
                        password = us.password,
                        logo = cs.logo
                    });
                    foreach (var q in query)
                    {
                        p              = new Payments();
                        p.country      = q.Country;
                        p.countryId    = q.countryId;
                        p.company_name = q.company_name;
                        p.address1     = q.address1;
                        p.address2     = q.address2;
                        p.city         = q.city;
                        if (q.expired != null)
                        {
                            p.expired = q.expired;
                        }
                        else
                        {
                            p.expired = null;
                        }
                        p.contactName = q.contactName;
                        p.zipcode     = q.zipcod;
                        p.customerId  = q.customerId;
                        p.role        = q.role;
                        p.userType    = q.UserType;
                        p.userId      = q.userId;
                        p.Email       = q.email;
                        p.password    = TransShip.Security.Security.Decrypt(q.password, new RijndaelManaged(), KEY);
                        p.status      = q.status;
                        p.state       = q.state;
                        p.logo        = q.logo;
                        user          = p;
                    }

                    if (user.customerId == 0)
                    {
                        var query2 = (from us in ctx.users
                                      where us.email == email
                                      select new {
                            userId = us.userId,
                            role = us.role,
                            UserType = us.user_type,
                            email = us.email,
                            password = us.password
                        });
                        foreach (var q in query2)
                        {
                            p          = new Payments();
                            p.role     = q.role;
                            p.userType = q.UserType;
                            p.userId   = q.userId;
                            p.Email    = q.email;
                            p.password = TransShip.Security.Security.Decrypt(q.password, new RijndaelManaged(), KEY);
                            user       = p;
                        }
                    }

                    return(user);
                }
            } catch (Exception e) {
                LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty));
                throw e;
            }
        }
 public Memberships_levels UpdateMemberShip(Memberships_levels members)
 {
     return(member.UpdateMember(members));
 }
 public Memberships_levels SaveMemberShip(Memberships_levels members)
 {
     return(member.SaveMemberShip(members));
 }