public string Delete(int id)
        {
            string             rpta;
            membership_history history = new membership_history();

            try {
                using (var ctx = new transshipEntities()) {
                    history = ctx.membership_history.FirstOrDefault(x => x.membership_HistoryId == id);

                    if (history != null)
                    {
                        ctx.Entry(history).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);
        }
        public string Delete(shipment_tracking tracking)
        {
            string            rpta;
            shipment_tracking shipTrack = new shipment_tracking();

            try {
                using (var ctx = new transshipEntities()) {
                    shipTrack = ctx.shipment_tracking.FirstOrDefault(x => x.shipmentId == tracking.shipmentId &&
                                                                     x.trackingId == tracking.trackingId &&
                                                                     x.userId == tracking.userId);

                    if (shipTrack != null)
                    {
                        ctx.Entry(shipTrack).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);
        }
        public string Delete(shipment_cost shipservice)
        {
            string        rpta;
            shipment_cost shipCost = new shipment_cost();

            try {
                using (var ctx = new transshipEntities()) {
                    shipCost = ctx.shipment_cost.FirstOrDefault(x => x.shipmentId == shipservice.shipmentId &&
                                                                x.service_typeId == shipservice.service_typeId &&
                                                                x.measure_unitId == shipservice.measure_unitId);

                    if (shipCost != null)
                    {
                        ctx.Entry(shipCost).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);
        }
        public string DeleteVendorContacts(vendor_contacts vendorcontacts)
        {
            string          rpta;
            vendor_contacts vendorContacts = new vendor_contacts();

            try {
                using (var ctx = new transshipEntities()) {
                    vendorContacts = ctx.vendor_contacts.FirstOrDefault(x => (x.vendorId == vendorcontacts.vendorId && x.contactId == vendorcontacts.contactId));

                    if (vendorContacts != null)
                    {
                        ctx.Entry(vendorContacts).State = EntityState.Deleted;
                        ctx.SaveChanges();

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

            return(rpta);
        }
Exemple #5
0
        public string DeleteAddres(int idAddress)
        {
            string rpta;
            recurring_addresses address = new recurring_addresses();

            try {
                using (var ctx = new transshipEntities()) {
                    address = ctx.recurring_addresses.FirstOrDefault(x => x.addressId == idAddress);

                    if (address != null)
                    {
                        ctx.Entry(address).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);
        }
Exemple #6
0
        public string DeleteRates(rates rates)
        {
            string rpta;
            rates  rate = new rates();

            try {
                using (var ctx = new transshipEntities()) {
                    rate = ctx.rates.FirstOrDefault(x => (x.vendorId == rates.vendorId && x.countryId == rates.countryId &&
                                                          x.service_typeId == rates.service_typeId && x.measure_unitId == rates.measure_unitId));

                    if (rate != null)
                    {
                        ctx.Entry(rate).State = EntityState.Deleted;
                        ctx.SaveChanges();

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

            return(rpta);
        }
        public string DeleteService(int id)
        {
            string        rpta;
            service_types service = new service_types();

            try {
                using (var ctx = new transshipEntities()) {
                    service = ctx.service_types.FirstOrDefault(x => x.service_typeId == id);

                    if (service != null)
                    {
                        ctx.Entry(service).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);
        }
Exemple #8
0
        public string DeleteCustomer(int id)
        {
            string    rpta;
            customers customer = new customers();

            try {
                using (var ctx = new transshipEntities()) {
                    customer = ctx.customers.FirstOrDefault(x => x.customerId == id);

                    if (customer != null)
                    {
                        ctx.Entry(customer).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);
        }
Exemple #9
0
        public string ChangePassword(int id, string email, string password, string newPass)
        {
            string   rpta;
            Users    user = new Users();
            Payments us;

            try {
                us = user.getUser(email);
                if (us.password == password)
                {
                    newPass = TransShip.Security.Security.Encrypt(newPass, new RijndaelManaged(), KEY);
                    users u = new users()
                    {
                        userId = id, email = email, password = newPass
                    };
                    using (var ctx = new transshipEntities()) {
                        ctx.users.Attach(u);
                        ctx.Entry(u).Property(x => x.password).IsModified = true;
                        ctx.Configuration.ValidateOnSaveEnabled           = false;
                        ctx.SaveChanges();
                    }
                    rpta = "Password was changed sucessfull";
                }
                else
                {
                    rpta = "Password incorrect";
                }
            } catch (Exception e) {
                LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty));
                throw e;
            }

            return(rpta);
        }
Exemple #10
0
        public string DeleteUnit(int id)
        {
            string        rpta;
            measure_units unit = new measure_units();

            try {
                using (var ctx = new transshipEntities()) {
                    unit = ctx.measure_units.FirstOrDefault(x => x.measure_unitId == id);

                    if (unit != null)
                    {
                        ctx.Entry(unit).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);
        }
        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;
            }
        }
        public membership_history UpdateHistory(membership_history model)
        {
            membership_history history = new membership_history();

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

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

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

                    ctx.SaveChanges();

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

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

                    ctx.SaveChanges();

                    return(service);
                }
            } catch (Exception e) {
                LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty));
                throw e;
            }
        }
Exemple #15
0
        public shipments updateShipment(shipments model)
        {
            shipments shipment = new shipments();

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

                    ctx.SaveChanges();

                    return(shipment);
                }
            } catch (Exception e) {
                LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty));
                throw e;
            }
        }
Exemple #16
0
        public recurring_addresses UpdateAddress(recurring_addresses model)
        {
            recurring_addresses address = new recurring_addresses();

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

                    ctx.SaveChanges();

                    return(address);
                }
            }catch (Exception e) {
                LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty));
                throw e;
            }
        }
Exemple #17
0
        public customers UpdateCustomer(customers model)
        {
            customers customer = new customers();

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

                    ctx.SaveChanges();

                    return(customer);
                }
            }catch (Exception e) {
                LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty));
                throw e;
            }
        }
Exemple #18
0
        public measure_units UpdateUnit(measure_units model)
        {
            measure_units unit = new measure_units();

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

                    ctx.SaveChanges();

                    return(unit);
                }
            } catch (Exception e) {
                LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty));
                throw e;
            }
        }
Exemple #19
0
        public users UpdateUser(users model)
        {
            users user = new users();

            model.password = TransShip.Security.Security.Encrypt(model.password, new RijndaelManaged(), KEY);
            user           = model;
            try {
                using (var ctx = new transshipEntities()) {
                    ctx.Entry(user).State = EntityState.Modified;

                    ctx.SaveChanges();

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