Core.ServiceResponse IContactService.RemoveContactByFullName(ContactServiceRequest contactServiceRequest) { if (contactServiceRequest.Contact == null) { return new Core.ServiceResponse() { Code = 400, Message = "Contact should not null" }; } if (string.IsNullOrEmpty(contactServiceRequest.Contact.FullName)) { return new Core.ServiceResponse() { Code = 400, Message = "ContactName should not null" }; } if (string.IsNullOrEmpty(contactServiceRequest.Id) || string.IsNullOrEmpty(contactServiceRequest.Token) || string.IsNullOrEmpty(contactServiceRequest.Type)) { return new Core.ServiceResponse() { Code = 400, Message = "Id Type and Token should not null" }; } string message = string.Empty; if (HP.TS.Devops.Security.SecurityCode.Success != HP.TS.Devops.Security.SecurityAction.CheckAccess(this.ConnectString, contactServiceRequest, out message)) { return new Core.ServiceResponse() { Code = 403, Message = contactServiceRequest.Id + " of type " + contactServiceRequest.Type + " have no access of " + message }; } ContactAction contactAction = new ContactAction(this.ConnectString); if (contactAction.RemoveContactByFullName(contactServiceRequest.Contact.FullName) <= 0) { return new Core.ServiceResponse() { Code = 500, Message = "Remove Contact Fail" }; } return new Core.ServiceResponse() { Code = 0, Message = "Success" }; }
Core.ServiceResponse IContactService.CreateContact(ContactServiceRequest contactServiceRequest) { if (contactServiceRequest.Contact == null) { return(new Core.ServiceResponse() { Code = 400, Message = "Contact should not null" }); } if (string.IsNullOrEmpty(contactServiceRequest.Contact.FirstName) || string.IsNullOrEmpty(contactServiceRequest.Contact.LastName) || string.IsNullOrEmpty(contactServiceRequest.Contact.EmailAddress) || string.IsNullOrEmpty(contactServiceRequest.Contact.Phone) || string.IsNullOrEmpty(contactServiceRequest.Contact.CreateBy)) { return(new Core.ServiceResponse() { Code = 400, Message = "FirstName LastName EmailAddress Phone CreateBy should not null" }); } if (string.IsNullOrEmpty(contactServiceRequest.Id) || string.IsNullOrEmpty(contactServiceRequest.Token) || string.IsNullOrEmpty(contactServiceRequest.Type)) { return(new Core.ServiceResponse() { Code = 400, Message = "Id Type and Token should not null" }); } string message = string.Empty; if (HP.TS.Devops.Security.SecurityCode.Success != HP.TS.Devops.Security.SecurityAction.CheckAccess(this.ConnectString, contactServiceRequest, out message)) { return(new Core.ServiceResponse() { Code = 403, Message = contactServiceRequest.Id + " of type " + contactServiceRequest.Type + " have no access of " + message }); } ContactAction contactAction = new ContactAction(this.ConnectString); if (contactAction.CreateContact(contactServiceRequest.Contact) <= 0) { return(new Core.ServiceResponse() { Code = 500, Message = "Create Contact Fail" }); } return(new Core.ServiceResponse() { Code = 0, Message = "Success" }); }
ContactServiceResponse IContactService.RetrieveContactByFullName(ContactServiceRequest contactServiceRequest) { if (contactServiceRequest.Contact == null) { return(new ContactServiceResponse() { Code = 400, Message = "Contact should not null" }); } if (string.IsNullOrEmpty(contactServiceRequest.Contact.FullName)) { return(new ContactServiceResponse() { Code = 400, Message = "ContactName should not null" }); } if (string.IsNullOrEmpty(contactServiceRequest.Id) || string.IsNullOrEmpty(contactServiceRequest.Token) || string.IsNullOrEmpty(contactServiceRequest.Type)) { return(new ContactServiceResponse() { Code = 400, Message = "Id Type and Token should not null" }); } string message = string.Empty; if (HP.TS.Devops.Security.SecurityCode.Success != HP.TS.Devops.Security.SecurityAction.CheckAccess(this.ConnectString, contactServiceRequest, out message)) { return(new ContactServiceResponse() { Code = 403, Message = contactServiceRequest.Id + " of type " + contactServiceRequest.Type + " have no access of " + message }); } ContactAction contactAction = new ContactAction(this.ConnectString); List <Contact> contacts = contactAction.RetrieveContactByFullName(contactServiceRequest.Contact.FullName); return(new ContactServiceResponse() { Code = 0, Message = "Success", Contacts = contacts }); }
Core.ServiceResponse IContactService.CreateContact(ContactServiceRequest contactServiceRequest) { if (contactServiceRequest.Contact == null) { return new Core.ServiceResponse() { Code = 400, Message = "Contact should not null" }; } if (string.IsNullOrEmpty(contactServiceRequest.Contact.FirstName) || string.IsNullOrEmpty(contactServiceRequest.Contact.LastName) || string.IsNullOrEmpty(contactServiceRequest.Contact.EmailAddress) || string.IsNullOrEmpty(contactServiceRequest.Contact.Phone) || string.IsNullOrEmpty(contactServiceRequest.Contact.CreateBy)) { return new Core.ServiceResponse() { Code = 400, Message = "FirstName LastName EmailAddress Phone CreateBy should not null" }; } if (string.IsNullOrEmpty(contactServiceRequest.Id) || string.IsNullOrEmpty(contactServiceRequest.Token) || string.IsNullOrEmpty(contactServiceRequest.Type)) { return new Core.ServiceResponse() { Code = 400, Message = "Id Type and Token should not null" }; } string message = string.Empty; if (HP.TS.Devops.Security.SecurityCode.Success != HP.TS.Devops.Security.SecurityAction.CheckAccess(this.ConnectString, contactServiceRequest,out message)) { return new Core.ServiceResponse() { Code = 403, Message = contactServiceRequest.Id + " of type " + contactServiceRequest.Type + " have no access of " + message }; } ContactAction contactAction = new ContactAction(this.ConnectString); if (contactAction.CreateContact(contactServiceRequest.Contact) <= 0) { return new Core.ServiceResponse() { Code = 500, Message = "Create Contact Fail" }; } return new Core.ServiceResponse() { Code = 0, Message = "Success" }; }