Beispiel #1
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);
        }
Beispiel #2
0
        public HttpResponseMessage Put(recurring_addresses model)
        {
            try {
                BORecurring_Addresses address = new BORecurring_Addresses();
                recurring_addresses   addr;

                addr = address.UpdateAddress(model);
                return(Request.CreateResponse(HttpStatusCode.OK, addr));
            } catch (Exception e) {
                ErrorMessage mensaje = new ErrorMessage("2.1", "Exception to update recurring address - " + e.GetBaseException().Message, e.ToString());
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, mensaje));
            }
        }
Beispiel #3
0
        public HttpResponseMessage GetOne(int idAddress)
        {
            try {
                BORecurring_Addresses address = new BORecurring_Addresses();

                var Address = new recurring_addresses();
                Address = address.getOneAddres(idAddress);
                return(Request.CreateResponse(HttpStatusCode.OK, Address));
            } catch (Exception e) {
                ErrorMessage mensaje = new ErrorMessage("2.1", "Exception to get recurring address - " + e.GetBaseException().Message, e.ToString());
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, mensaje));
            }
        }
Beispiel #4
0
        public recurring_addresses getOneAddress(int idAddress)
        {
            var address = new recurring_addresses();

            try {
                using (var ctx = new transshipEntities()) {
                    ctx.Configuration.LazyLoadingEnabled = false;
                    address = ctx.recurring_addresses.Where(x => x.addressId == idAddress).SingleOrDefault();
                }
            }catch (Exception e) {
                LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty));
                throw e;
            }
            return(address);
        }
Beispiel #5
0
        public recurring_addresses SaveAddress(recurring_addresses model)
        {
            var address = new recurring_addresses();

            try {
                using (var ctx = new transshipEntities()) {
                    address = ctx.recurring_addresses.Add(model);
                    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;
            }
        }
Beispiel #6
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;
            }
        }
 public recurring_addresses UpdateAddress(recurring_addresses model)
 {
     return(address.UpdateAddress(model));
 }
 public recurring_addresses SaveAddress(recurring_addresses model)
 {
     return(address.SaveAddress(model));
 }