public int CreatePhoneDestination(int ownerAlertId, int communicationTypeId, string phoneName, string phoneNumber, string phoneCarrier) { if (db.tbl_OwnerAlertDestinations.Any(q => (q.OwnerAlertId == ownerAlertId) && q.OwnerAlertDestinationName == phoneName && q.OwnerAlertDestinationText == phoneNumber && q.OwnerAlertDestinationAdditionalText == phoneCarrier)) { return(-1); } // Initialise the Owner Alert Destination tbl_OwnerAlertDestinations model = new tbl_OwnerAlertDestinations() { OwnerAlertId = ownerAlertId, OwnerAlertCommunicationTypeID = communicationTypeId, OwnerAlertDestinationName = phoneName, OwnerAlertDestinationText = phoneNumber, OwnerAlertDestinationAdditionalText = phoneCarrier, OwneralertEnabledYN = true }; try { // Insert the object into the database db.tbl_OwnerAlertDestinations.AddObject(model); db.SaveChanges(); return(model.DestinationID); } catch (Exception ex) { var message = ex.Message; return(0); } }
public int CreateEmailDestination(int ownerAlertId, int communicationTypeId, string emailName, string emailAddress, string destinationAdditionalText) { if (db.tbl_OwnerAlertDestinations.Any(q => (q.OwnerAlertId == ownerAlertId) && (q.OwnerAlertDestinationName == emailName || q.OwnerAlertDestinationText == emailAddress))) { return(-1); } // Initialise the Owner Alert Destination tbl_OwnerAlertDestinations model = new tbl_OwnerAlertDestinations() { OwnerAlertId = ownerAlertId, OwnerAlertCommunicationTypeID = communicationTypeId, OwnerAlertDestinationName = emailName, OwnerAlertDestinationText = emailAddress, OwnerAlertDestinationAdditionalText = destinationAdditionalText, OwneralertEnabledYN = true }; try { // Insert the object into the database db.tbl_OwnerAlertDestinations.AddObject(model); db.SaveChanges(); return(model.DestinationID); } catch (Exception ex) { var message = ex.Message; return(0); } }