public string DeleteContact(int idContact) { string rpta; customer_contacts contact = new customer_contacts(); try { using (var ctx = new transshipEntities()) { contact = ctx.customer_contacts.FirstOrDefault(x => x.contactId == idContact); if (contact != null) { ctx.Entry(contact).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 HttpResponseMessage Put(customer_contacts model) { try { BOContacts contact = new BOContacts(); customer_contacts cont; cont = contact.UpdateContact(model); return(Request.CreateResponse(HttpStatusCode.OK, cont)); } catch (Exception e) { ErrorMessage mensaje = new ErrorMessage("2.1", "Exception to update contacts - " + e.GetBaseException().Message, e.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, mensaje)); } }
public customer_contacts SaveContact(customer_contacts model) { var contact = new customer_contacts(); try { using (var ctx = new transshipEntities()) { contact = ctx.customer_contacts.Add(model); ctx.SaveChanges(); return(contact); } }catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } }
public customer_contacts UpdateContact(customer_contacts model) { customer_contacts contact = new customer_contacts(); contact = model; try { using (var ctx = new transshipEntities()) { ctx.Entry(contact).State = EntityState.Modified; ctx.SaveChanges(); return(contact); } }catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } }
public decimal CreateUser(CreateUserObject createUserObject, string baseURI) { var stopwatch = new Stopwatch(); stopwatch.Start(); var returnValue = (decimal)0; var passwd = string.Empty; using (var dbTran = _transshipEntities.Database.BeginTransaction()) { try { var newCustomer = new customers { company_name = createUserObject.companyname, countryId = createUserObject.idCountry, city = createUserObject.city, estimated_membership = createUserObject.membership, address1 = createUserObject.addr1, address2 = createUserObject.addr2, zipcode = createUserObject.zipcode, status = "P", register_date = DateTime.Today, state = createUserObject.usstate }; _transshipEntities.customers.Add(newCustomer); passwd = TransShip.Security.Security.Encrypt(DateTime.Now.ToString(), new RijndaelManaged(), TransShip.Security.Security.GenerateKey(new RijndaelManaged(), 256)); var newUser = new users { customerId = newCustomer.customerId, full_name = createUserObject.fullname, email = createUserObject.email, password = TransShip.Security.Security.Encrypt(createUserObject.keyinformation, new RijndaelManaged(), KEY), user_type = "C", status = "I", role = "A", confirmationKey = passwd }; _transshipEntities.users.Add(newUser); var newContact = new customer_contacts { customerId = newCustomer.customerId, full_name = createUserObject.fullname, title = createUserObject.title, phone_number = createUserObject.phonenumber, email = createUserObject.email }; _transshipEntities.customer_contacts.Add(newContact); _transshipEntities.SaveChanges(); returnValue = newUser.userId; dbTran.Commit(); } catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); } finally { stopwatch.Stop(); LogBook.TextLog.Info(string.Format("Ellapsed time {0} milli seconds", stopwatch.ElapsedMilliseconds)); var emailhandler = new TransShip.EMailHandler.EMailHandler(); emailhandler.SendConfirmationEmail(string.Format("your registration has been successful, TranShip will contact you "), string.Format("{0}?apiInformation={1}", baseURI, HttpUtility.UrlEncode(passwd)), createUserObject.email); } } return(returnValue); }
public customer_contacts UpdateContact(customer_contacts model) { return(contact.UpdateContact(model)); }
public customer_contacts SaveContact(customer_contacts model) { return(contact.SaveContact(model)); }